感谢尼兰巴。它起作用了!。这是我的最后一个代码:
$menu_middle_left = array(
\'theme_location\' => \'middle-left\',
\'menu\' => \'\',
\'container\' => \'\',
\'container_class\' => \'\',
\'container_id\' => \'\',
\'menu_class\' => \'\',
\'menu_id\' => \'\',
\'echo\' => true,
\'fallback_cb\' => \'wp_page_menu\',
\'link_before\' => \'\',
\'link_after\' => \'\',
\'walker\' => new Walker_Nav_Menu()
);
wp_nav_menu($menu_middle_left);
我把你的代码放在我的函数中。php:
function custom_walker_nav_menu_start_el($item_output, $item, $depth, $args){
$output = \'<div class="buttons-\'.$item->ID.\'" title="some_title">\';
$output .= $item_output;
$output .= \'</div>\';
return $output;
}
add_filter( \'walker_nav_menu_start_el\', \'custom_walker_nav_menu_start_el\' , 10, 4 );