Add a .last class to the last in each ul.sub-menu

Put the following in your functions.php class SH_Last_Walker extends Walker_Nav_Menu{ function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields[‘id’]; //If the current element has children, add class ‘sub-menu’ if( isset($children_elements[$element->$id_field]) ) { $classes = empty( $element->classes ) ? array() : (array) $element->classes; $classes[] = ‘has-sub-menu’; $element->classes =$classes; } // We don’t … Read more

add span class inside wp_nav_menu link anchor tag

Have you tried using the before or link_before parameters in your array arguments when declaring your wp_nav_menu function? Note: use after or link_after for the opposite effect. Example, wp_nav_menu( //normal arguments here….etc ‘before’ => ‘<span class=”arrow”></span>’, //or ‘link_before’ => ‘<span class=”arrow”></span>’, ); From the Codex: $before (string) (optional) Output text before the of the link … Read more

Pulling Featured Images in to a WordPress Menu

You can do that by filtering the menu objects using wp_nav_menu_objects filter. The following example will replace all titles of the menu items pointing to posts or pages with an <img> tag of the post or page thumbnail if available. It will target a menu with a name of Posts Menu called in theme using … Read more

How to add ul class on nav

It’s simple just you need to add items_wrap parameter and add or edit class attr: wp_nav_menu( array( ‘theme_location’ => ‘top-menu’, ‘container’ => false, ‘items_wrap’ => ‘<ul class=”nav your_custom_class”>%3$s</ul>’, ));

Add custom page link with anchor

I was searching for an answer for this but suddenly I got the idea and it works! In the menu settings just add the anchor link just like an html link code <a href=”#anchor” >titulo </a> So with WP is the same but only adding the anchor in the field link This will create the … Read more

How do I add nested categories to drop-down menu in twenty-eleven?

As a purely theory example, this is how I would approach the problem: $cats = get_categories(); echo ‘<ul>’; foreach($cats as $cat) { echo'<li>’.$cat->name; if($cat->parent != 0) { $subcats = get_category(‘child_of=”.$cat->cat_ID; echo “<ul>’; foreach($subcats as $subcat){ echo ‘<li>’.$subcat->name.'</li>’; } } echo ‘</li>’; } echo ‘</ul>’; I don’t expect that to work fully as I coded it … Read more