1028 posts
    Has referred 500+ members Has sold $500,000+ on Envato Market Has collected 50+ items on Envato Market Elite Author: Sold more than $75,000 on Envato Market
+6 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
    Has been part of the Envato Community for over 4 years Has referred 1+ members Located in Europe Sells items exclusively on Envato Market
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