我有一个将类添加到锚定标记的解决方案。
1: 步骤:在函数中添加此项。php
function add_additional_class_on_a($classes, $item, $args)
{
if (isset($args->add_a_class)) {
$classes[\'class\'] = $args->add_a_class;
}
return $classes;
}
add_filter(\'nav_menu_link_attributes\', \'add_additional_class_on_a\', 1, 3);
2: 然后在你的主题中这样使用它
<?php
// Show Menu here
wp_nav_menu(array(
\'theme_location\' => \'my-footer-menu\',
\'menu_class\' => \'footer-top list-unstyled\',
\'add_a_class\' => \'box-link text-dark\',
));
?>