1028 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a File in an Envato Bundle
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 500 and 999 users
+1 more
ThemeBlvd says

So I have been playing with Wordpress 3 and trying to create a navigation menu with the new menu manager feature. I’m struggling a little with accomplishing what I want using the wp_nav_menu() function.

Basically, I’m trying to get it to list out the menu with no container div and no ul tag. The reason I’m trying to do this is because I generally like to apply some sort of custom styling to the first button in the menu.

So, I’m trying to figure out how to configure the arguments in the function so my markup can look something like this:

<ul>
    <li class="first"><a href="" title="">HOME</a></li>
    <?php wp_nav_menu($args); ?> 
</ul>

I’ve been trying to follow the different parameters here, but there’s not a whole lot of information yet:

http://codex.wordpress.org/Function_Reference/wp_nav_menu

I figured out that if I set the container argument to blank like “container=”, it will remove the default wrapping div, but haven’t been able to figure out how to strip away the ul tag (similar to how with wp_list_pages(), you can use “title_li=”) . Any ideas on how to do this?

Also, if there’s a better way to add special styling to that first menu item and I’m going about this all wrong, please chime in! :-)

70 posts
  • Europe
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
sergiupopa says

This code adds a class to the parent ‘ul’ directly

// Add the UL class to support Superfish function wp_nav_menu_add_menuclass($ulclass) { return preg_replace('/<ul>/', '<ul class="sf-menu">', $ulclass, 1); } add_filter('wp_nav_menu','wp_nav_menu_add_menuclass'); </ul></ul>

Try to remove the ‘ul’ by replacing it with nothing:

// Add the UL class to support Superfish function wp_nav_menu_add_menuclass() { return preg_replace('/<ul>/', '', '', 1); } add_filter('wp_nav_menu','wp_nav_menu_add_menuclass'); </ul>
by
by
by
by
by
by