如何调用导航标签的值(如:Home,about us,contacs)并将其设置为属性名称?
like this: <a href="#text" class="active"> get this value!!! </a>
并在此处显示:
<a SHOW IT HERE ==> data-menuanchor="get this value!!!" <== SHOW IT HERE href="#text"> get this value </a>
我想在我的functions.php中使用类似的东西:
function my_nav_menu_attribs( $atts, $item, $args ){
$atts['data-menuanchor'] = 'get this value!!!';
}
并且即使我将来添加其他标签也可以使其工作,如下所示:
<a href="#text" data-menuanchor="first label"> first label </a>
<a href="#text" data-menuanchor="second label"> second label </a>
$atts['data-menuanchor'] = 'label_number';