你应该使用沃克类这种东西。这里是你可以使用
class MyWalker extends Walker_Nav_Menu
{
function display_element ($element, &$children_elements, $max_depth, $depth = 0, $args, &$output)
{
// check, whether there are children for the given ID and append it to the element with a (new) ID
$element->hasChildren = isset($children_elements[$element->ID]) && !empty($children_elements[$element->ID]);
return parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
}
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
// you know can access $item->hasChildren to do anything you want..
}
}
如果你只是想克服它,那么你应该使用jQuery的HTML添加到父元素的简单学步车类。你可以做这样的事情。
jQuery(document).ready(){
jQuery('ul#id > li').prepend('<img src="#" alt="">');
}