admin管理员组文章数量:1304960
I have a menu listing all of my products categories in Woocommerce. I need to add an attribute data-relation
to each <li>
tag and the value for each one would be the ID of the category.
I success to do it for the <a>
tag. Does it exist a filter for <li>
?
Here is the PHP filter function:
function category_menu_id_attribute ($atts, $item, $args) {
$atts['data-relation'] = $item->object_id;
return $atts;
}
add_filter('nav_menu_link_attributes', 'category_menu_id_attribute', 10, 3);
Thank you for the help.
本文标签: phpAdd data attribute to each li in menu
版权声明:本文标题:php - Add data attribute to each li in menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741783804a2397462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论