I’m trying to customize a core WP function using my functions.php file. Why won’t my code work? This just adds a <div class=\"shield\"> around the ul.
function my_start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<div class=\"shield\"><ul class=\"sub-menu\">\n";
}
function my_end_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul></div>\n";
}
add_filter('start_lvl', 'my_start_lvl');
add_filter('end_lvl', 'my_end_lvl');
I don’t know if it’s related but I’m using the Carrington framework for my theme.
There are no filters named
'start_lvl'or'end_lvl'. So your code is never called. I guess you want to change the output of a custom menu (your question is very vague).If so – use a custom walker instead.