311 Responses

  1. Ryan
    Ryan June 1, 2010 at 9:00 am | | Reply

    Another excellent article as always! Thanks Justin :)

  2. Jean-Baptiste Jung
    Jean-Baptiste Jung June 1, 2010 at 10:48 am | | Reply

    Excellent post. Thanks!

  3. Michelle
    Michelle June 1, 2010 at 10:49 am | | Reply

    Thanks for the tutorial, it’s very helpful for me!

  4. Matt Orley of the Remarkable Team

    Hooray can’t wait! This and new post templates will certainly convince me to utilize Wordpress more than Joomla moving forward. The world is changing so fast and so GOOOD for web developers! Matthew Orley, Peninsula, OH

    1. Bruno Brant
      Bruno Brant June 1, 2010 at 4:23 pm | | Reply

      “The world is changing so fast and so GOOOD for web developers!”

      I would say: “The WORD is changing so fast and so GOOOD for web developers!” =)

  5. testbeta
    testbeta June 1, 2010 at 11:00 am | | Reply

    thanks for the write up Justin!

    was the new theme Twenty Ten based on similar theme as justinadlock.com is? or justintadlock.com using the twenty ten?

  6. Jinnat Ul Hasan
    Jinnat Ul Hasan June 1, 2010 at 11:06 am | | Reply

    Thanks Justin to round-up the menu system. WordPress 3.0 menu system just looks amazing.

  7. Andrew Nacin
    Andrew Nacin June 1, 2010 at 11:28 am | | Reply

    Hi Justin,

    I like is_nav_menu_active() and we’re likely going to add it to core. Do you think you could prefix it in your tutorial?

    Also, get_nav_menu_locations() returns an array in the form of $locations[$location] => $menu_id, so the the argument should be $location instead of $menu.

    We recognize that the terminology used in function names may be confusing at first, as a theme registers a “nav menu” but really you’re just registering a location. If you have any suggestions, let us know.

    Nacin

  8. Andrew Nacin
    Andrew Nacin June 1, 2010 at 11:30 am | | Reply

    After bouncing around a few ideas, looks like we’re going to go with has_nav_menu( $location ). You’ll see it in trunk soon.

  9. Jeff Starr
    Jeff Starr June 1, 2010 at 11:38 am | | Reply

    Superb!

    Incredible work once again, Justin :)

  10. Chris Creed
    Chris Creed June 1, 2010 at 11:42 am | | Reply

    Cheers Justin for the thorough review – I also get lots of support requests about creating custom menus, so this new update is going to make things much easier.

  11. Lucian
    Lucian June 1, 2010 at 2:45 pm | | Reply

    Hey Justin, that’s a really detailed article that will help many for sure.
    I have a question though. Do you think is possible to show sub-pages only for the current parent page, in the sidebar for example. The sub-pages for the other parents will colapse.

    I wrote an article about this method, but it needs an outdated plugin to work and is not tweaked to work for categories.
    http://bit.ly/csLd4L

    Some insight on this would be appreciated by community as it is very popular in larger websites navigation.

    1. Saulyz
      Saulyz December 25, 2010 at 5:02 pm | | Reply

      This is exactly what I’m looking for quite a long time.

  12. Sawyer
    Sawyer June 1, 2010 at 2:48 pm | | Reply

    Great overview, this will be very helpful!

  13. Justin Tadlock On Menus In WP 3.0 June 1, 2010 at 2:59 pm |
  14. Jeffro
    Jeffro June 1, 2010 at 3:13 pm | | Reply

    Hey Justin, we have sidebars for widgets and we can drag widgets around to rearrange them. What are the areas called that house menus? Simply nav containers? Or Navigational sidebars? Also, is there any similarity between the widget system and how menus work outside of rearranging stuff?

  15. paul
    paul June 1, 2010 at 4:48 pm | | Reply

    very detailed tutorial. I’ll bookmark it for the future.

    thanks Justin

  16. Mike Smith
    Mike Smith June 1, 2010 at 6:07 pm | | Reply

    Awesome article Justin. Very, very detailed. I’ve saved it to delicious, shared it via twitter and am going to go over all of this for my themes. I’ve got the basics down for the menus, but this is definitely a step up from where I am at right now with them.

  17. Kel
    Kel June 1, 2010 at 8:21 pm | | Reply

    Great writeup! Of course, if you don’t see it coming, let me be the first to offer: Child Menus – It could happen :)

  18. Jörn
    Jörn June 1, 2010 at 8:42 pm | | Reply

    It seems like the new has_nav_menu still has problems after menus are deleted. On my test blog the function return true although no menus are left. I already filed a ticket at the Trac.

    1. Andrew Nacin
      Andrew Nacin June 2, 2010 at 1:11 am | | Reply

      I’ve since closed your ticket with a fix. :-)

  19. Andrew
    Andrew June 2, 2010 at 1:18 am | | Reply

    Great tutorial! This deserves to be bookmarked because it is really helpful in a lot of ways.

  20. Rilwis
    Rilwis June 2, 2010 at 8:14 am | | Reply

    Wonderful article. All information about the new menu system is gathered here. Thanks for sharing.

  21. cehwitham
    cehwitham June 2, 2010 at 8:23 am | | Reply

    I’m using 3.0-RC1-15092.

    I currently have the follwoing options for menu items:

    * URL
    * Navigation Label
    * Title Attribute

    I don’t have the following that are shown in your screenshot:

    * CSS Classes
    * Link Relationship (XFN)
    * Description
    * Link Target (Please note that a kitten dies every time a link is opened in a new window/tab.)

    CSS Classes would be amazingly useful. Do I have to turn this functionality on or is it not available in my release?

    Really helpful post.

    1. kucrut
      kucrut June 2, 2010 at 9:58 pm | | Reply

      they’re hidden in the ‘Screen Options’ :)

      1. Global_1981
        Global_1981 June 25, 2010 at 6:26 pm |

        Awesome thanks saved me a lot of frustration!

      2. kevin
        kevin September 29, 2010 at 11:42 am |

        Same as Global and Markgt, thanks!

    2. Markgt
      Markgt July 21, 2010 at 6:25 am | | Reply

      Thanks @kucrut for that tip! been looking all over for that :)

  22. cehwitham
    cehwitham June 2, 2010 at 8:26 am | | Reply

    Just found that I can turn these options on using the Screen Options panel.

    Many thanks.

  23. Jörn
    Jörn June 2, 2010 at 11:27 am | | Reply

    Thanks Justin for your ongoing work and help.

    Your theme framework hybrid is great. I read about your article about the small things that matter and I found tons of those fantastic small details inside your theme.

    Everytime I wanted to add new functionality to my own theme I found that you already implemented this in hybrid.

    I hope you don’t mind, that I added some code to the new version of my theme. I really liked the way you named your hooks and I thought it is a good decision not to reinvent the wheel again (who wants to have square wheels when he can have round ones).

    Your site is already inside my readme.html inside the themes folder and I won’t stop to praise your knowledge.

  24. kucrut
    kucrut June 2, 2010 at 11:42 pm | | Reply

    Just found out that it’s kind of impossible to get a valid markup with the current implementation of wp_nav_menu. If you try to add the same item (eg. page) to more than one menu and display those menus on the same page, you’ll get duplicate IDs.

    Is there any workaround for this or could this be considered as a bug?

  25. Christian Zumbrunnen
    Christian Zumbrunnen June 3, 2010 at 2:37 am | | Reply

    Fantastic post. Thanks for your clear, understandable, tutorial-like information.
    It helps a lot in understanding WP-menus.

  26. Carlos
    Carlos June 3, 2010 at 3:27 am | | Reply

    Thanks for the tutorial, looks like you got all the “How-To´s” for menus in WP3.0 down in one post-excellent!

    Not too sure about the Kittens Dying though – personally speaking I prefer it when a link opens in a new tab.

  27. Arnoud
    Arnoud June 3, 2010 at 5:31 am | | Reply

    This is indeed a very nice 3.0 feature. I’m working on this at the moment.
    Does anyone know how to show only the childs of the active parent, for instance in the sidebar?

    [mainmenu] = only level 1 items
    [submenu] = only show level 2 of specific level 1 parent

    I’ve been looking al over for this, but can’t seem to find it.
    It should be possible, since it was possible with ‘wp_list_pages’.

    Hope someone can help me out!

  28. Dr. Lawrence Kindo
    Dr. Lawrence Kindo June 3, 2010 at 12:04 pm | | Reply

    I was trying to tinker with the menu system in the wordpress dashboard and was quite thrilled about the output. Simple for the user but a tad bit of hard work for those behind wordpress 3.0. Welcoming the new version of wordpress!! Cheerios!

    I really like how you have elaborated on the menu system in the new wordpress.

  29. Webbhotell
    Webbhotell June 3, 2010 at 1:23 pm | | Reply

    Excellent post again Justin

    This is awesome feature and there’s so many other cool features upcoming so i really hope Wordpress 3.0 os being released soon.

  30. Steve
    Steve June 3, 2010 at 3:32 pm | | Reply

    2.9.2 works perfectly fine. Little in the new package has any useful value for us.

    1. James
      James June 4, 2010 at 8:30 pm | | Reply

      And never mind the new features that streamline development and save countless hours of hacking, or the fact that with this release WordPress can finally be called a CMS out of the box.

    2. Mark
      Mark June 6, 2010 at 10:40 pm | | Reply

      And just to dog pile Mr. Steve a little bit further…

      Mr. Steve: Please do NOT use the word us when expressing something which is solely your own opinion—especially when it’s an unpopular one. Thanks!

  31. Philip
    Philip June 4, 2010 at 4:39 am | | Reply

    Thanks Justin, I’m a Wordpress newbie but confident that with resources available like this I can only keep improving. I’m particularly interested in the collapsible menus but probably need to focus more on some of the basics first. I’ll be vistiting again!

  32. James
    James June 4, 2010 at 9:52 am | | Reply

    One thing I’d love to be able to do is use the description text you can define for each link and have it rendered inside a span tag within the link. So far no luck at all. Has anyone else succeeded with this?

    Also on the version of 3.0 I’m playing with, using using “after” as an array puts text after the entire link, not within it but after the link text.

  33. Peter
    Peter June 4, 2010 at 10:00 am | | Reply

    Thanks Justin, I’m just looking at how best to implement v3 menus so this post is timely and very much appreciated..

  34. Kenneth Younger
    Kenneth Younger June 4, 2010 at 2:19 pm | | Reply

    How you are getting the #primary-menu CSS ID to show up? All I’ve been able to get working there is class names.

  35. Daily Digest for June 5th June 5, 2010 at 7:53 am |
  36. Kevinjohn Gallagher
    Kevinjohn Gallagher June 5, 2010 at 2:17 pm | | Reply

    Hi Justin,

    Thanks for this great preview.
    I’m wondering if you happen to have seen any examples of the following:

    1) A “Walker” class

    Its great being able to call one, but if we could see one in action or a tutorial anywhere or on the codex, it would make life alot easier.

    2) The ability to call certain levels of a menu separately/specifically

    When using “wp_list_pages( $args );” we can specify DEPTH and CHILD OF.

    Effectively allowing us to call out a sub menu for display somewhere else.

    I’m confident both of these are around somewhere, i’m sorry, i just can’t find any info on them myself. I’d appreciate any information anyone has.

    Thanks
    Kev

  37. Hover
    Hover June 6, 2010 at 11:46 am | | Reply

    Fantastic!

    Very much looking forward to WordPress 3.0!

  38. Weekend Roundup #86 June 7, 2010 at 11:15 am |
  39. Ads
    Ads June 7, 2010 at 9:51 pm | | Reply

    Not sure if anyone else has had issues with register_nav_menus() and wp_nav_menu() or not but here’s my rant…

    In my functions.php i have:

    register_nav_menus(array('global' => __('Global')));

    in my header.php i have:

     'global')); ?>

    And i have the menu set to the appropriate location in the admin dashboard.

    My issue is that i do not get the child pages rendered out to the page. The ul/li combo is only for top level pages only. Even if i use 'depth' => 3 in the wp_nav_menu arg array it still fails to show children.

    Any ideas? I’m using 3.0-RC2-15161

    Thanks.

  40. Ads
    Ads June 7, 2010 at 9:56 pm | | Reply

    Sorry, my previous post should have read…

    in my header.php i have:

    wp_nav_menu(array('theme_location' => 'global'));
  41. Timothy
    Timothy June 8, 2010 at 8:41 am | | Reply

    This is fantastic, thanks!

    Two questions for anybody generous enough to respond:
    1) I want to use accordion menus, where the accordion ‘tabs’ are UI only, and do not link to anything – just click and the menu’s sub-items fold out. Any better way to do this using the menu system than to create blank top-level pages or setting the URL of these menu items to ‘#’?
    2) Is there a way to promote the menus option to a top-level item in the admin area? I would like most users to be able to modify the menus (WP working as a CMS in this case), but I do not want them to see all the Appearance options.

    Thanks again for a fantastic explainer for this new feature!

  42. Ed Nailor
    Ed Nailor June 8, 2010 at 1:39 pm | | Reply

    Playing with WP 3.0 RC1, I found that when adding a Custom Post Type, I was able to include these on the new Menu, which was very cool. However, since then, I have started the site I was working on with a fresh database (dropped the database tables) and now the Custom Post Type items aren’t available for my new Menu. Everything seems to be the same, so I am sure I have missed some step somewhere. Do you have any insight on this?
    Ed

  43. Aurel Wong
    Aurel Wong June 8, 2010 at 2:13 pm | | Reply

    Hi Justin,

    I am glad to find your blog.
    I believe your blog will help me to improve my blogging skill .
    Thank you.

    Regard,
    Aurel Wong

  44. Ed Nailor
    Ed Nailor June 8, 2010 at 2:27 pm | | Reply

    OMG! I just found this… I knew I wasn’t loosing it!

    When you are on the Custom Menu page in the admin, clicking on the Screen Options in the top right corner allow you to include more options with your Custom Menus. Included in this was a checkbox for my new Custom Post Type, along with Posts, Link Targets, CSS classes and descriptions!

    NOW THAT IS COOL!

  45. Johnnie
    Johnnie June 8, 2010 at 3:13 pm | | Reply

    Hi guys, what options are available for the ‘fallback_cb’ =>” function?
    I would like my sub-menu to load up if no menu found instead of “wp_page_menu”

    Thanks!

    1. James Tryon
      James Tryon August 16, 2010 at 10:25 am | | Reply

      Im looking to do the same thing. Did you get this to work?

      Im using a child theme of twenty ten.

  46. Mel
    Mel June 9, 2010 at 5:44 pm | | Reply

    I’m glad that nav menus are being addressed. A welcome upgrade.

  47. Lonny
    Lonny June 9, 2010 at 6:24 pm | | Reply

    The only think I don’t like about Justin Tadlock is that he doesn’t publish WordPress 3.0 stuff every day of the week. Because when he does, it is well thought out and documented.

    Too bad WP is open-source, else Ma.tt ought to hire Justin to do the WP documentation.

  48. Adam
    Adam June 11, 2010 at 4:19 pm | | Reply

    I am so glad I found this site months ago. I have been experimenting with a lot of different tricks from justin and they are working great. Thanks J

  49. Lox
    Lox June 12, 2010 at 3:28 pm | | Reply

    Don’t be to exited about the new menu system. It is is intentionally incomplete.

    For example there is NO filter to filter the generated array of menus items. So, say goodbye to sub-menu and portions of menu display, you won’t be able to do it with a powerful wordpress filter.

    Why? Because the wordpress dev team has refused to include ONE more line of code and delayed it to WP 3.1.

  50. NightMan
    NightMan June 12, 2010 at 4:02 pm | | Reply

    Hello everyone!

    Is it possible add link to home page? I use multilanguage plugin and have 2 home pages (“/” and “/ru/”), so I can not add link with static URL… all working very good with pages and categories, but I also need home page link :)

    1. Glenn
      Glenn June 23, 2010 at 8:46 am | | Reply

      This has been added since the release of 3.0, but it’s a bit hidden. In the new ‘Menus’ section of WP, click the ‘View All’ tab on the ‘Pages’ box. You should see a checkbox for ‘Home’.

  51. cristiana
    cristiana June 13, 2010 at 4:51 am | | Reply

    My website is based on wordpress them. I need to add this.Thanks man

  52. Benjamin Knight
    Benjamin Knight June 14, 2010 at 1:44 pm | | Reply

    I’m wondering if it’s recommended to use this new feature to control a site’s main navigation menu or only for creating smaller, secondary menus. I would imagine it is since nobody wants to use plugins or forwarding if they want to have links to non-pages such as category indexes or other sites. When creating a main navigation menu then, it would be nice then if there were a way to select all pages and add them to a menu such that their order and parent/child structure were preserved.

    Other than that, all praise to the WordPress development team for a great new feature!

  53. Johan
    Johan June 15, 2010 at 1:59 pm | | Reply

    Is there a way to get the “Menu name” in the same fashion you use title_li= with wp_list_pages() …

    Or you will have to use Static name above the menu.

    For example a sidebar menu.

  54. Kyle
    Kyle June 16, 2010 at 10:28 am | | Reply

    Anyone have any idea on how to do a quick export/import of custom menus?
    I’m using a framework for multiple sites and it would be nice to do an easy import/export for each site instead of recreating them each time.

    Thanks,
    ~Kyle~

    1. Marc
      Marc August 20, 2010 at 4:52 am | | Reply

      @kyle – Did you find a plan for this? I’m looking for the same functionality. Thanks.

    2. Marc
      Marc September 15, 2010 at 4:59 am | | Reply

      This would be especially great for complex/long menus/navigations.

  55. stephan
    stephan June 17, 2010 at 12:42 am | | Reply

    Hey Justin,

    thanks for this great article and overview. I tried to use theese functions for my template but I got the issue, that the wordpress won’t save the assigments I create in the admin panel. After choosing which menu is located in the theme and pressing save, everything seems all right, but on the site he simply shows the menu with the lowest ID. After refreshing the apperance/menu site the assigment is lost again. When I use the twentyten theme it works nicely and I can not figure out my misstake. Any suggestions?

    Im running WP3.0 RC3 and here is my code:

    http://nopaste.php-q.net/296509

    thanks and best regards
    stephan

  56. Wordpress 3.0 Roundup | Themergency June 17, 2010 at 12:02 pm |
  57. Leo
    Leo June 18, 2010 at 11:46 am | | Reply

    Thanks for the post, but one problem that I notice or unless I am doing something wrong is that a custom created link doesn’t get the current-menu-item class if it is the active link.

    Anyone else experience this?

    1. Justin
      Justin December 21, 2010 at 7:57 am | | Reply

      I had the same issue – it definitely needs the trailing slash.

      I’m wondering how to have this home link work across servers (dev, staging, live) and still get the current-menu-item option. If I use just “/” it doesn’t get the class at all. Anyone have experience with this?

      Great tutorial (and name) Justin!

      1. Justin
        Justin December 21, 2010 at 11:02 am |

        For now, I left the custom home link as “/” only and added a class to it to give it the same property as the current-menu-link class when on the home page. Works locally and live without having to update the link

  58. Cancasa
    Cancasa June 18, 2010 at 5:12 pm | | Reply

    Can’t wait until I start using this enhancement.

  59. Govindji Patel
    Govindji Patel June 18, 2010 at 6:04 pm | | Reply

    I just upgraded to 3.0 and I do not have Menus in Appearance menu is there anything I need to do to get it there.

    1. ColtonCat
      ColtonCat September 13, 2010 at 4:10 pm | | Reply

      Maybe you should actually read this post, that is what it explains.

  60. Josh
    Josh June 19, 2010 at 5:11 pm | | Reply

    Thanks for the article. Have you been able to figure out how to display things like the custom description?

  61. Troy
    Troy June 21, 2010 at 4:43 pm | | Reply

    Hi Justin,

    I am wondering if you know why I am now longer able to add my single posts to the nav bar. Is there a support function I need to add for this now. It works in the beta versions. I have my featured image showing in the navigation via the nav-menu-template.php file. Since posts are no longer supported the functionality stopped working. When I add a custom link it also doesnt work. Is there a quick fix or support function for this, or do you have any ideas for an alternative way to show the featured image from a custom link added in the nav. Thanks very much

    Troy

  62. Troy
    Troy June 21, 2010 at 4:47 pm | | Reply

    I should have read for a minute longer. Thanks Ed.

    Ed Nailor
    June 8, 2010 at 2:27 pm | Permalink | Reply
    OMG! I just found this… I knew I wasn’t loosing it!

    When you are on the Custom Menu page in the admin, clicking on the Screen Options in the top right corner allow you to include more options with your Custom Menus. Included in this was a checkbox for my new Custom Post Type, along with Posts, Link Targets, CSS classes and descriptions!

    NOW THAT IS COOL!

  63. Dave Immerz
    Dave Immerz June 21, 2010 at 8:53 pm | | Reply

    I’m also experiencing the problem of the ‘current-menu-item’ class not working. I’m not sure if it’s supported using the new menu system as it’s not in the source code?

    Hopefully I’m wrong and someone has a solution…

    1. Rich
      Rich July 2, 2010 at 3:25 am | | Reply

      I had the same thing and it turned out to be a conflicting style from my css. If you can then use FireBug to find out what style is naturally being applied to the unselected navigation items. If its something like this:
      #nav ul li a {}
      then a simple .current-menu-item {} will not work. You have to target it in the same way as the pre-existing style, like this:
      #nav ul li.current-menu-item a {}
      Hope this helps.

  64. Darrell
    Darrell June 21, 2010 at 11:59 pm | | Reply

    I think you have the after and link_after (also the before) backwards, but looks like you wrote this in beta, so that could be it. I am using ‘link_after’ = | and my pipe is showing after the text but within the link. >a<Text|>/a< (Hopefully that HTML went through). I use ‘after’ to put my string after and outside the link element.

    Also do you know if you can not show the ‘after’ on the last link? I looks silly as I am trying to using my pipe string as a link delimiter.

  65. William Lindley
    William Lindley June 22, 2010 at 8:10 am | | Reply

    A nightmare to maintain, spaghetti bowl of desynchronization, is what these new menus are. They statically replicate what we already had dynamic widgets for. In database lingo, they violate third normal form.

    Post and page descriptions are computed from the page content AT ADD TIME; if you update a post or page, its description is not updated, so you have to remember to manually edit each menu entry each time you edit something. Adding pages, or changing a page’s Order, or changing a page’s Parent, does not change the menu, you have to manually go replicate all your changes in two places.

    Nor can I find any way to write a widget that creates menu items, like my http://wordpress.org/extend/plugins/hierarchical-pages/ , which would solve the above problems by creating menus on the fly, based on your current page location, the N latest posts, or other inputs.

    In short, the new menus should have been a widget, that could be inserted anywhere, instead of a whole new structure. What a mess.

  66. Riccardo
    Riccardo June 22, 2010 at 10:00 am | | Reply

    I’ve created a user with role set as Editor and he can’t see Appearance->Menus.

    I want that he could edit the Menus.

    How could I let him see the Appearance->Menus button?

  67. Jose Random
    Jose Random June 22, 2010 at 6:50 pm | | Reply

    Thanks for the article. I think Wordpress 3.0 is one of the greatest things that ever happened to blogosphere, or even to the world! Hey, I’m not exaggerating. It’s really cool.

  68. Maria
    Maria June 23, 2010 at 8:46 am | | Reply

    Hi, could you give us a tip how to make the submenu horizontal instead of the dropdown? Can’t find any code for that anywhere. Is it possible using tme new 3.0 menus?

    Thanks in advance :)

    1. ColtonCat
      ColtonCat September 13, 2010 at 4:15 pm | | Reply

      Just search for superfish or go here Superfish – Suckerfish on Steroids

  69. Whiskeyjim
    Whiskeyjim June 23, 2010 at 3:00 pm | | Reply

    First Justin, thanks for being a leader in website development across the Internet. I’m not sure you hear that enough:)

    I’m a little surprised by this first implementation of menus to the Wordpress core, which is long overdue given menu prevalence in website accessibility. And yes, that is a swipe at the Wordpress community.

    Several things seem extraordinarily short sighted. First, The wp_nav_menu() call is inconsistent with the existing wp_page_menu() function. Why is that?

    Second, why not build in automatic inclusion of sub-pages? That alone is going to cause incredible amounts of administrative time and confusion, etc.

    Third, there is no shortcode or other easy, theme independent method to embed the menus in pages and posts. Why not? It would seem this capability is one of the most common needs of end users (witness all the plug-ins), and one of the easiest to implement.

    I’m not ranting, just expressing surprise at the current implementation to one of the gurus of Wordpress, who in my view always develops with vision. Thanks man.

  70. Vincent Klaiber
    Vincent Klaiber June 23, 2010 at 6:39 pm | | Reply

    Thanks, I am upgrading my website for 3.0 right now so it helped out a lot!
    Keep up the good work!

  71. Dennis Winter
    Dennis Winter June 23, 2010 at 11:26 pm | | Reply

    Hey Justin,

    THAT is a great article on Wordpress 3.0 and it’s awesome menu management!
    But I’ve got one little question: Has anyone tried to display the “description” attribute? I’m running into heavy problems with it and there is no documentation about it, searched Google up to page 50 but nothing showed up.

    Thanks in advance,
    Dennis

  72. Stephen Cronin
    Stephen Cronin June 24, 2010 at 2:03 am | | Reply

    Hi Justin,

    Absolutely fantastic article as usual.

    However, I think it would be worth you pointing out to your readers that if a) a theme is used by other people and if b) some of those people may be on earlier versions of WordPress, then you really need to check if the register_nav_menu function exists before calling it. Otherwise you get a fatal error. It’s a similar story with wp_nav_menu.

    I’ve written about this in my Practical Theme Support For WordPress 3.0 Menus post, if people want to see how to do it – or maybe you could update this post to mention it?

    Regardless, thanks for an excellent post – this is where I learned how to support menus in the themes I’m working on.

  73. Web Solutions and Design - Asteriskr June 25, 2010 at 11:23 am |
  74. Angelia
    Angelia June 25, 2010 at 10:07 pm | | Reply

    Just lost quite a bit of time figuring out a little issue I just came across, and thought this info might come in handy for someone. I have been following and developing with all of the new 3.0 features since they began and have yet to see it mentioned or documented anywhere.

    (note: Justin, it would be great if this info were added to the post where you go over adding custom post types with pre_get_posts )

    If you are using the new nav_menu features, even straight out of the box from twenty ten, and you also have custom post types that you would like to add to the $query to show up conditionally i.e. ( if is_author ), and you run the pre_get_posts function to add them, if you do not include nav_menu_item as one of the post types to return, your navigation menu will no longer show up on, for example in this instance, your authors.php remplate.

    It is important to be aware that nav_menu_item is now a registered core/builtin post type.

    Hope that saves someone else some time lost ;-)

    1. nickmorss
      nickmorss August 17, 2010 at 4:39 am | | Reply

      thanks, the @Angelia ‘nav_menu_item’ was what i needed. Just now to get rid of the Warning: Illegal offset type in isset or empty in /home/public_html/wp/wp-includes/post.php on line 736

    2. Derrick Walker
      Derrick Walker November 12, 2010 at 12:36 pm | | Reply

      Thanks Angelia! I have been looking for a solution for my missing custom menu on my category and tag pages. This fixed it.

  75. Jasmine Soona
    Jasmine Soona June 26, 2010 at 4:47 am | | Reply

    Thanks for this! I love tinkering around with the code of Wordpress; totally geeky, but I feel like I get to let out a little bit of creativity on each of my blogs :)

  76. Avio karte
    Avio karte June 26, 2010 at 6:33 am | | Reply

    Hooray!!! This is great news. I will look more into it and probably upgrade.

  77. Barrett Golding
    Barrett Golding June 26, 2010 at 10:04 am | | Reply

    Has anyone figured how to insert a separator, like ” | “, btwn links wp_nav_menu? Adding parameter 'after' => ' | ' results in a trailing pipe:
    Link1 | Link2 | Link3 |

    I could grab menu html before the echo() and do a trim(), but wondering if there’s a mo’ better way?

    (I now see Darrell asked this above, but no harm re-querying.)

    1. Rich
      Rich July 1, 2010 at 5:53 am | | Reply

      You could always do this with classes if there is no current support for this. You could either use ‘li’ separators or ‘background-image’ and position to get the look and feel you need.

      1. Rich
        Rich July 2, 2010 at 3:14 am |

        Forgot to mention you could use a ‘last-child’ / ‘first-child’ class to avoid displaying the unwanted separator at the beginning or end of your menu. (only as a last resort! please do post up an answer to this if you find one)

  78. Anthony
    Anthony June 27, 2010 at 3:28 pm | | Reply

    How can I use superfish with nav_menu ?

  79. Benjamin Knight
    Benjamin Knight June 29, 2010 at 5:50 pm | | Reply

    This interface needs dramatic improvement… it’s really a nightmare to create menus on WP installations that have large, complex page structures. The search function doesn’t appear to work… it appears to be searching page bodies, not titles.

  80. KC
    KC June 30, 2010 at 5:04 pm | | Reply

    I’m making changes to my business’s blog and will definitely pass this on to my developer. I know he had some questions in this area and hopefully this will take care of his confusion. Thanks.

  81. marcelo araujo
    marcelo araujo July 1, 2010 at 6:37 am | | Reply

    hi justin!!
    in the ‘theme_location’ iside php arraya we must change to the same name that exists in the ‘tab’ theme location, or this param id fix, i must remain this text ‘theme_location’. im testing but i have not sucess.
    thanks!

  82. gabsy
    gabsy July 1, 2010 at 8:06 am | | Reply

    Any idea how to get menu item title attribute to be displayed as link_after ? or any other posibilities to have individual link_after text for each menu item ?

  83. Will Barker
    Will Barker July 1, 2010 at 11:34 pm | | Reply

    Thanks for this Justin,

    Could you expand on how you have added the sub menu indicators in your example menus? there isn’t a class or markup added to li’s that contain a child list to style, how did you do that? for example, superfish requires a sf-sub-indicator class i think.

    Thanks

    Will

  84. ge fanuc series
    ge fanuc series July 3, 2010 at 10:15 am | | Reply

    Wordpress 3.0 has been great. They really set a standard for keeping updated.

  85. Christopher
    Christopher July 3, 2010 at 11:42 am | | Reply

    Thank you! This was what I needed to start implementing the new menus in my custom theme.

  86. Agus Suhanto
    Agus Suhanto July 3, 2010 at 11:59 pm | | Reply

    I’m trying to create WordPress 3 menu programmatically.

    Here is the code that I wrote to make it:

    $menu_id = wp_create_nav_menu('my_menu');
    wp_update_nav_menu_item($menu_id, 0, array('menu-item-title' => 'First Menu Item', 'menu-item-url' => 'http://suhanto.net', 'menu-item-status' => 'publish'));

    and now I want to assign the $menu_id to “Primary” navigation location. I already looked into the source code in wp-includes/nav-menu.php and wp-includes/nav-menu-template.php and so far I haven’t found a function that achieves that goal.

    So, do you know how to assign a menu id to “primary” navigation location programmatically in WordPress 3.0?

    1. Agus Suhanto
      Agus Suhanto July 4, 2010 at 2:16 am | | Reply

      Finally I found the answer for my question above. I already wrote the answer here as the answer to my own question in WordPress forum: http://wordpress.org/support/topic/419242?replies=2.

  87. Karl B
    Karl B July 4, 2010 at 8:05 am | | Reply

    Great information.

    I love the idea of this but am unsure how much control of the menu you can do with it. I tried it on a project I am working on where if you are on a ‘book’ single post I need the menu to highlight book and if on ‘blog’ post highlight blog. I cannot see how I would attain this using the menu.
    In 2.9 I would use wp_list_categories and use a function for the highlighting like this: http://paste-it.net/public/o76011d/

    Is this doable with 3.0 menus?

    Thanks,
    Karl

  88. Yunus
    Yunus July 5, 2010 at 1:18 am | | Reply

    Thanks for your good works.

  89. Gabriel Tadeu
    Gabriel Tadeu July 5, 2010 at 6:02 am | | Reply

    Anyone know how ‘description’ works? I cant print with custom menu…

  90. mati
    mati July 6, 2010 at 4:29 am | | Reply

    in “custom url” the menu dont get the “current-menu” class, how in your example – the “home” is show as active?

    (sorry og my english)

  91. mati
    mati July 6, 2010 at 4:45 am | | Reply

    oops… you are right, in custom url – the wp tray to find if it is the currnt page- but in my case it have a little bug! the function tray to compare the “custom url” with $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']

    and in my case I dont gave the slash in my home page custom url – and the result is that it not get the current-menu-item class.

    my wp-home -url: localhost/wordpress
    my custom menu url: localhost/wordpress

    I get open a ticket in wp-trac…

    (sorry of my english)

  92. mati
    mati July 7, 2010 at 3:24 pm | | Reply
  93. Nikesh
    Nikesh July 8, 2010 at 3:26 am | | Reply

    hey , justin pretty neat article there , but i kind of am facing a altogether new issue , i want to remove the container itself

    i found something on the wordpress codex

    Removing the Navigation Container

    but cannot seem to figure out how to use it

  94. martin
    martin July 8, 2010 at 1:18 pm | | Reply

    Hi, I only want to ask why the new menu system supports only 16 items? Tanks in advance.

  95. Matt
    Matt July 9, 2010 at 2:51 pm | | Reply

    I am having trouble just showing children of a section in a sidebar. What can I do just to show the dropdown children in the sidebar? Been looking everywhere, can you help?

  96. matt
    matt July 9, 2010 at 5:46 pm | | Reply

    @Barrett Golding

    your li:first-child tidbit is a GODSEND. thanks man.

    cheers!

    1. Kevinjohn Gallagher
      Kevinjohn Gallagher July 13, 2010 at 10:27 am | | Reply

      Hi Matt,

      Just so you know the :first-child selector is a CSS2.1 pseudo-class, and isn’t offically supported in all the browsers. Be careful when relying on them for fancy or vital formatting :)

  97. Jennifer
    Jennifer July 10, 2010 at 1:08 pm | | Reply

    This is a great tutorial. It was very helpful. I went nuts adding menus to a theme I’m playing with – what fun!

    One question: do you or anyone know why the menus option might not display on a WordPress 3 installation? The owner installed WP 3.0 and the 3.0 themes now work, but he can’t add menus as there is no “menu” option under appearances. Back to Google I go. :-)

  98. Debbie Campbell
    Debbie Campbell July 11, 2010 at 7:29 pm | | Reply

    Great post, very easy to add menu support to my custom theme. Thank you.

  99. Pakblogger
    Pakblogger July 12, 2010 at 12:20 am | | Reply

    I hadn’t heard of this before thanks , this is quite useful.

  100. Jason
    Jason July 13, 2010 at 3:25 am | | Reply

    With the introduction of Menus in WP 3.0, this has superseded the old codex wp_list_pages(). However, this has brought about a coding problem for the navigation menu when dealing with Private pages.

    Whenever there are Private pages present, the Menus (in Admin >> Appearance) doesn’t list them. This requires a search first before they can be added onto the Menu. Unfortunately, when one’s logged out, the Private pages are still shown on the navigation menu and not hidden.

    I believe it’s something to do with the WP 3.0 codex wp_nav_menu().

    Any ideas to fix this?

  101. Mrmist
    Mrmist July 13, 2010 at 9:39 am | | Reply

    Thanks for putting this information down, it’s helped me to integrate menu support properly.

  102. Rem
    Rem July 15, 2010 at 2:03 am | | Reply

    I’ve seen early screenshoots where you can add “Posts” to menu. But categories and pages are available now.

    Is there any way I can add specific “posts” to menu ? Also Specific page of custom post type? I think there is code for it already in core, but not sure.

  103. Benjamin Knight
    Benjamin Knight July 15, 2010 at 11:28 pm | | Reply

    It would be nice if there was a function akin to “get_menu_items” that returns an array of objects for each menu nav item, similar to get_posts or get_pages. This would allow developers to be able to directly access the data which has a plethora of advantages, including more control over display or working with other applications. In the meantime I’ll probably just query the database.

  104. Roelof
    Roelof July 17, 2010 at 4:34 pm | | Reply

    Also a great Post… Wordpress 3 is much better than the vers. before.
    Extreme SEO Google Internet Marketing.

  105. Jennifer R
    Jennifer R July 17, 2010 at 8:49 pm | | Reply

    I don’t know why wordpress does not add the menu function by default to the main admin menu? we must register it to the theme for it :(

  106. Leland
    Leland July 24, 2010 at 1:17 am | | Reply

    Hey all ,

    How do we go about adding the “home” link via Custom Link from the new WP3 menu builder but also have it assigned a “current_menu_item” class when we are viewing the index page. What is the best way to append a “home” link to these new menus? Thank you.

    1. Bradford
      Bradford July 26, 2010 at 9:57 pm | | Reply

      I found that it worked when you created a custom link WITH the trailing slash. It wouldn’t work without it, however if you do include the trailing slash (http://theblawblog.com/ in my case) it works.

  107. kamal
    kamal July 24, 2010 at 7:55 am | | Reply

    ONE Word : I LOVE YOU ;)

    ___________
    (Yeah it’s 3)

  108. Frank Anthony
    Frank Anthony July 24, 2010 at 2:20 pm | | Reply

    Is it a bug or a feature that the following doesn’t work without a menu created?

    wp_nav_menu( array( 'container' => 'nav') );

    I want to include this function in a basic html5 framework theme, but if no custom menus are created yet and it falls back to a standard page list it doesn’t change anything…. it’s still an unordered list wrapped in a div with class=”menu”.

    'container' => 'false' doesn’t remove the wrapper div as expected either.

    1. Frank Anthony
      Frank Anthony July 24, 2010 at 3:21 pm | | Reply

      Ok, I see now that it is a feature.

      It falls back to wp_page_menu()

      So you can either filter that function or create your own function and change

      'fallback_cb'     => 'wp_page_menu'
    2. davidn
      davidn February 7, 2011 at 2:46 pm | | Reply

      I am also facing the problem that ‘container’ => ‘false’ is ignored. My problem game up after creating a “empty” child theme of a theme where ‘container’ => ‘false’ works fine. Have you figured out anything?

  109. Robin Anderson
    Robin Anderson July 27, 2010 at 10:10 pm | | Reply

    I’ve been searching for an example of the echo option. I want to use the new menu structure (I have it in place), however I am using wp-ecommerce, which I can’t seem to get the product categories added to the new 3.0 structure. I want to return the menu, then test for a certain page, so I can output my own menu in php.

    Can someone either help me insert the product categories (not manually) into the main menu, or understand how the menu is returned when echo is false.

    (I’m using latest version of wp-ecommerce and wp 3.0)

    Thanks so much, Robin

    1. Robin Anderson
      Robin Anderson July 27, 2010 at 10:42 pm | | Reply

      Never mind, being a dummy. It’s the same as wp_list_pages() echo it returns a string.

  110. Aj
    Aj July 28, 2010 at 11:01 pm | | Reply

    Hi, i’m a begginer, so can somebody explain how to make primery menu? i should edit functions.php file. and this file is at host server? ishould paste

    add_action( 'init', 'register_my_menu' );
    
    function register_my_menu() {
    	register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );
    }

    to the end of file functions.php?

  111. Ryan
    Ryan July 29, 2010 at 1:18 pm | | Reply

    Very informational post Justin. I’m also really glad to see the custom Menus in WordPress 3.0. I have finally had an opportunity to experiment a bit, and I have been very pleased. However, I have come across my first problem. I want to apply a class to the actual link anchor, but the class I specify in the “CSS Classes” field is applied to the list element. I am currently trying to work around this, but I was just curious, what is your take on this?

    1. Ryan
      Ryan July 29, 2010 at 1:20 pm | | Reply

      Ouch.. *informative

  112. dallas
    dallas July 31, 2010 at 5:07 pm | | Reply

    By changing line 163 in “wp-includes/nav-menu-template.php” from:

    $menu_items = wp_get_nav_menu_items( $menu->term_id);

    to

    $menu_items = wp_get_nav_menu_items( $menu->term_id, $args);

    the args list is passed along to wp_get_nav_menu_items (which already has a filter). it was pretty simple to use that filter, check for a “child_of” arg (which is now passed through from our “wp_nav_menu” call) and call a custom function based on the wp_list_pages filtering:

    function get_menu_children($parentID, $menu_items){
                $menu_list = array();
                foreach ( (array) $menu_items as $item ) :
                    if ( $item->menu_item_parent == $parentID ) :
                        $menu_list[] = $item;
                        if ( $children = $this->get_menu_children($item->ID, $menu_items) )
                            $menu_list = array_merge($menu_list, $children);
                    endif;
                endforeach;
                unset($children);
                return $menu_list;
            }

    That’s worked great to allow retrieving a sub-nav section of my menu while only changing one line of the WP core.

    wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary', 'child_of' => 43 )) 

    I’m sure there is a better way but this was the simplest for my WP-noob brain and didn’t require a bunch of hacking.

  113. Davit
    Davit August 1, 2010 at 6:45 am | | Reply

    Great article, as usual. However the term Theme Location I think needs some further explanation. For example why there appeared a need in such a thing at all. Why not just define individual menus directly?

  114. Duy
    Duy August 10, 2010 at 11:54 am | | Reply

    Hi Justin,

    Do you know how to differentiate a ‘li’ which has children items and a ‘li’ without ones?

    For example, here is my list:

    -Home
    -Products
    – Product #1
    – Product #2
    - About

    What I want is the ‘Products’ will have an arrow, or styled differently since it contain children while other ‘li’s don’t.

    Thanks for great article btw.

    Duy

  115. Matt Edminster
    Matt Edminster August 11, 2010 at 3:25 am | | Reply

    What advice could you offer for an attempt to style a menu with children as a dynamic submenu (following the approach described at http://www.triah.com/2010/01/09/color-menu-with-dynamic-submenu-using-css/) rather than nested drop-downs?

    Seems to me that the catch comes in wrapping parent links in one div and all child-links in another. Is there anyway to do this using one menu as opposed to creating a menu for parents and each child?

  116. Eric Boyer
    Eric Boyer August 13, 2010 at 12:37 pm | | Reply

    I can’t for the life of me get posts to list under the new nav function. Can anyone give me a hand?

    Just like the navigation on THIS site… Writing -> Fiction -> *list of posts*. This is exactly what I’m looking to do.

  117. JeremyT.
    JeremyT. August 13, 2010 at 11:28 pm | | Reply

    Not sure where you find the time to compose such detailed posts, but thank you heaps. I’m a WordPress newbie and the CMS and how to use it does overwhelm me sometimes. Your tuts make WordPress life a little easier…:)

  118. hnla
    hnla August 15, 2010 at 4:51 am | | Reply

    A great article that helped me understand applying the new wp_nav_menu.

    I have one question that has me stumped after a far bit of research.

    I am trying to extract the menu name a user may create and then attach to a menu region, I realise that the menu assigned to a particular region is not apparently the business of nav-menu.php ?

    I can access two arrays $_wp_registered_nav_menus() , and wp_get_nav_menus() for all the regions and menu objects yet I can’t find a means to correlate the two sets.

    For example I want to create a label from the menu name a user creates .

    I can’t know in advance the menu name or to what region the user assigns a given menu.

    I need to be able to do something along the lines of ‘If this region give me the menu parts assigned to just this region’.

    Not sure if that makes a whole lot of sense but any thoughts or pointers in the right direction would be hugely helpful.

  119. alsd
    alsd August 18, 2010 at 9:04 am | | Reply

    ‘depth’ is not working for wp_nav_menu?

    I have a parent category with a handful of subcategories, and I thought I will be getting this in a nested unordered lists that would allow me to style a dropdown menu:

    Parent menu
    -Sub menu 1
    - Sub menu 2

    Instead I am getting this:

    Parent menu
    Sub menu 1
    Sub menu 2

    My post in WordPress forum
    http://wordpress.org/support/topic/wp_nav_menu-not-displaying-subcategories

  120. rowland
    rowland August 18, 2010 at 4:59 pm | | Reply

    I need help with something that I haven’t found an answer to.

    I have one business with three storefronts. Each storefront has a website. I have not yet used MU, but am in the process of figuring how to set that up now. (Thanks for your help!) Related to that:

    I am not blogging on these three sites, but will within a few months. For now, my issue relates to Pages on my WP website.

    The three websites (one for ea storefront) will be identical. All three storefronts will share some pages. Each store, however, will have a couple of unique pages. I want to be able to update the shared pages and have all three websites update. HOWEVER, I want each store manager to be able to update their own unique pages. I don’t want managers to have access to another store’s pages. I don’t want the managers having access to the pages that span all three stores.

    Can this be done? If so, how?

    Thanks.

  121. Rob Watson
    Rob Watson August 19, 2010 at 11:42 am | | Reply

    Justin,

    Great article, and thanks for being so good about responding to peoples’ questions.

    I’m currently scratching my head over the Classes settings. A client wants me to create a wordpress theme and gave me an xhtml template and CSS2 stylesheet with the following navigation styles defined.

    #nav1
    {
    	height:57px;
    	background:url('http://example.com/img/top1.png') no-repeat top center;
    }
    #nav1 a, #nav2 a
    {
    	display:block;
    	height:57px;
    	float:left;
    	border:none;
    }
    #nav2 #navHome
    {
    	width:119px;
    	background:url('http://example.com/img/nav1.jpg') 0px 0px no-repeat;
    }

    Now, these are CSS ids, so I converted them to classes by removing the # and replacing it with a .

    .nav1
    {
    	height:57px;
    	background:url('http://example.com/img/top1.png') no-repeat top center;
    }
    .nav1 a, .nav2 a
    {
    	display:block;
    	height:57px;
    	float:left;
    	border:none;
    }
    .nav2 .navHome
    {
    	width:119px;
    	background:url('http://example.com/img/nav1.jpg') 0px 0px no-repeat;
    }

    But, when I put “nav2 navHome” in the Classes setting, the menu items don’t style correctly. The rendered source shows up like this: Home but the design falls apart and is just linked text without the nav1.jpg button graphic.

    What am I doing wrong?

    Thanks.

  122. Rob Watson
    Rob Watson August 19, 2010 at 11:44 am | | Reply

    Oops. just realized the code i pasted in my comment for the rendered source actually got rendered in the browser as a link.

    Here it is with a the pre tag wrap, hoping that will display the code. Otherwise, just view source, I guess. Home News

  123. tudor
    tudor August 19, 2010 at 7:10 pm | | Reply

    Hi. my menu doesn’t appear in the Appearance -> Menus panel.

    I’ve tried with the default code from http://codex.wordpress.org/Navigation_Menus, i’ve tried my code, nothing works.

    The menu still doesn’t appear in the Appearance -> Menus panel.

    If someone knows what’s the problem, please share. :)
    Thanks.

    1. matt
      matt March 29, 2011 at 3:08 pm | | Reply

      Hi. I’m having the same issue. “my menu doesn’t appear in the Appearance -> Menus panel.”

      Does anyone have a solution to this, or have the same issue?

      I’ve created multiple menu’s, and they are all available in the “Theme Locations” dropdowns (and display correctly on the site) but the tabs which should be in the right column of the Menus page are not available and/or do not display. I can only create new ones, and not edit current ones.

      Please help!

  124. Rob Watson
    Rob Watson August 19, 2010 at 7:24 pm | | Reply

    I figured out why it’s not styling. The classes are for the anchor tag but the menu system applies the class name to the list, not the anchor. Any way around this or will I need to revamp the CSS and template link code to resemble a list?

    1. Bernhard
      Bernhard September 12, 2010 at 7:35 am | | Reply

      Hi Rob,

      maybe I’m late and you found the solution:

      .nav2 .navHome a

  125. Paul
    Paul August 22, 2010 at 3:24 pm | | Reply

    Great article! Thank you!

    Can you also tell us how to access and display “description”? I’m trying to find such function but I can’t get it anywhere.

    If you could help those seeking for such function (I noticed a few people asking for that on this page) that would be awesome!

  126. Arturex
    Arturex September 6, 2010 at 4:31 pm | | Reply

    Thankks Justin,
    But i have a question sometimes we need to call an external page in a popup but i dont want the url to show or just want a new page I just to call it uding javascript:window.open() but now if i want to use the nav menu i dont have it as an options since always ask me for a url.. is there a way to do this?

  127. Bill
    Bill September 7, 2010 at 2:09 pm | | Reply

    It would be great if there were a way to automatically add the title attribute, at least using the link text, instead of needing to add copy and paste it in every time a new page is added to a menu.

    Does anyone know if there’s a way to do this by chance?

  128. Kenneth Henderson
    Kenneth Henderson September 7, 2010 at 9:21 pm | | Reply

    Here’s how to show the description and other parameters in the menu…

    // Hook nav rules to showing description page
    // Look details information by this page wp-includes/nav-menu-template.php
    // or by this link - http://core.svn.wordpress.org/trunk/wp-includes/nav-menu-template.php
    add_filter('walker_nav_menu_start_el', 'description_in_nav_el', 10, 4);
    function description_in_nav_el($item_output, $item, $depth, $args){
        $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
        $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
        $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
        $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
    
        return preg_replace('/([^<]*?)</', "" . "{$item->title}{$item->post_content}<", $item_output);
    }
    1. Piet
      Piet May 18, 2011 at 11:02 pm | | Reply

      can’t get this to work out of the box, it basically only shows the descriptions and nothing else anymore. Shouldn’t it only show the descriptions when hovering over it? Thanks!

  129. WebVostro
    WebVostro September 8, 2010 at 3:00 am | | Reply

    I comprehend how to register a menu for a theme, but honestly, for those of us who are a little lack in the programming dept, it can get somewhat confusing.

    Thanks for sharing – you made the task a lot easier.

  130. Arturex
    Arturex September 8, 2010 at 11:31 am | | Reply

    Hi Again here i am playing with the menus, and a question came up my head,
    as i look to the generated code it seems to me way to long something like this..

    <li id="menu-item-309" class="menu-item menu-item-type-post_type menu-item-309".....

    is thre a way that if i dont need such a big classes of differents id's an option to generate a simpler class lets say something like

    <li class="menu-item "...

    just to make it look cleaner, but leave the ptin to put all of it if needed..

  131. davoscript
    davoscript September 9, 2010 at 11:20 am | | Reply

    A great thing would be if a function (or procedure) exist to create the custom menu with its options at once, this way we could set custom menus as default.

    I’ve been researching about this, but didn’t have any luck yet (and the lack of documentation doesn’t help) .. any suggestions?

    Regards,
    Nice article Justin.

  132. Boysen Hodgson
    Boysen Hodgson September 9, 2010 at 3:28 pm | | Reply

    Do you know of any plugin conflicts?

    Menu is installed to upgrade an older site – Menu Admin shows up fine. I have upgraded 2 or three other clients without issue.

    When I SAVE the ‘mainmenu’ into the primary menu location … it’s not STICKING. I go to the dashboard, I come back … and no menu is selected.

    And what shows up on the site is a List Pages of everything, rather than the menu I was specifying. Any help appreciated.

    Thanks.

  133. Bernhard
    Bernhard September 12, 2010 at 8:39 am | | Reply

    Hi Justin,

    great tutorial for a great feature of Wordpress 3!

    Sure custom menus is now only version 1.0 and I didn’t expect something like that to come upto I’ve seen it.
    But the more you get, the more you want…

    Is there any possibility to move a parent menu item including all it’s children from one menu to another? Maybe a plugin?
    Also I would like to have the possibility to hide children in the admin panel for having better overview but to show more than one menu at the same time (this would be necessary to be able to move menu items from one menu to another).
    Another goodie would be an option to select for example 18 items in the add menu items box and add them directly as children of an existing menu item.

    Are there any plugins for customizing the admin panel for custom-created menus?

  134. Amanda
    Amanda September 20, 2010 at 2:22 am | | Reply

    Is there a way to include a search term in the menu? For example, I have a menu item “post category” (news), and I want children of that to be “latest posts”, “posted a week ago”, “posted a month ago”, etc

  135. angga
    angga September 22, 2010 at 4:09 am | | Reply

    how to get menu item.
    i don’t want ul or div tags.
    just menu items data

    help please

  136. Mike Goodstadt
    Mike Goodstadt September 25, 2010 at 5:17 am | | Reply

    Maybe I missed it but can someone give me a hint/link/snippet for how to control or change the default WP menu animation style.
    At the moment it slides down (sloooowly depending on the browser/OS/machine) on mouse over.
    I would like it to be onClick (revealing at the same time the parent page) and quicker or even without slide/animation.
    Do I really have to hack ‘nav-menu.dev.js’???
    How would I integrate the SuperFish plugin as mentioned abouve without messing up the WP one?
    Grateful for all pointers as there seems to be zero documentation on the effect used.

  137. Mike Goodstadt
    Mike Goodstadt September 25, 2010 at 12:53 pm | | Reply

    Ok Ok all have a wee snigger – it’s in the Hybrid theme itself – the ONLY js there is… and extremely easy to edit to ones own taste – and call by myself when I un-commented the line in the Skeleton template :-)
    I am sooo used to hacking my way through the coding undergrowth that I forgot that this is not virgin territory and we have our own Quatermain (or Challenger or Muntz depending on your century…) boldy going…
    Thanks Justin and all at DevPress!

  138. Christian
    Christian September 29, 2010 at 3:41 am | | Reply

    Thanks a lot, you saved me a lot of time.

    Greetings from
    Germany

  139. Zero
    Zero September 30, 2010 at 11:43 am | | Reply

    This Rocks !!!!!!!!

  140. Sahil
    Sahil October 2, 2010 at 1:41 am | | Reply

    Very Details and Awesome Tutorial, I was looking for a tutorial on Custom Menu for such a long time, Found many but they never explained in so depth. Great Work Cheer:)

  141. Fredrik Andersson
    Fredrik Andersson October 2, 2010 at 4:30 pm | | Reply

    Hi,

    It worked out perfectly for me to make the design and functions as i wanted with the menu. BUT then come the problem, when I have a network, how should this work then?

    I switch back to hardcoded just because that problem ;)

  142. Petra
    Petra October 4, 2010 at 11:30 am | | Reply

    That’s a great tutorial. However, I have a problem.. My menu consists of pages and categories, but when I view the website in a web browser I can only see the pages. Is there a code needed to view categories as well? (I do have some posts in those categories by the way.)
    Your help would be much appreciated.
    Thanks.

  143. Robin
    Robin October 5, 2010 at 3:37 am | | Reply

    It would be great to know how to remove all the extra big classes crap on menu items.

  144. Stacey Moore
    Stacey Moore October 8, 2010 at 7:01 am | | Reply

    Thanks for the very useful info. Regarding your request for a “menu logic” plugin… You can use widget logic on menus within the custom menu widget.

    1. Ray
      Ray August 23, 2011 at 3:45 pm | | Reply

      Wouldn’t this mean you’d have to use widgets **and** menus though?

  145. Srikanth AD
    Srikanth AD October 10, 2010 at 6:09 pm | | Reply

    Your tutorial helped me to create a drop down menu with some (non hyper-linked) parent items.

    Thanks

    1. Manish
      Manish February 7, 2011 at 4:16 am | | Reply

      Hi Srikanth,

      I’m building a theme and using wp_nav_menu to display menus. I’m wondering how to have parent page link from not linking to a page since child items are the once with information.

      Reading your comment, I think you’ve accomplished this. If, can you please share how or point me in the right direction.

      Thank you in advance.

      1. Manish
        Manish February 7, 2011 at 10:21 am |

        Hi, I resolved this myself. I simply created a custom link at Appearance > Menus and then added the name of the page there as the label. Once it’s in the menu I replaced Parent page with the custom link I just created. Then I expanded custom link and removed the URL.

        Thanks for this thread and it helped me on my thinking process.

  146. Yahya
    Yahya October 19, 2010 at 10:16 am | | Reply

    Hey Justin, the parameters list proves to be an awesome load of info! Thanks man! =D

  147. Rob
    Rob October 19, 2010 at 10:13 pm | | Reply

    Is it possible to insert onmouseover and onmouseout events via the wp_nav_menu menu insertion function?

    For example, I’d like to take this wp_nav_menu generated code:

    <a href="http://example.com/blog/?page_id=16" rel="nofollow">News

    and insert onmouseover/onmouseout like this:

    <a href="http://example.com/blog/?page_id=16" rel="nofollow">News

    Is that supported somehow in the args passed to wp_nav_menu? I’ve read the Codex, but can’t wrap my head around how to do this.

    Thanks.

  148. Rob
    Rob October 19, 2010 at 10:15 pm | | Reply

    Grr. I can’t get code to appear in my comments. See http://wordpress.org/support/topic/onmouseover-events-in-wp_nav_menu for what I mean.

  149. James
    James October 21, 2010 at 2:04 pm | | Reply

    Hey Justin,

    I have a client that is always asking for custom menus for a group of pages. I.E. the page Dogs and the 3 sub pages, Husky, Hound and Terrier all display the same menu but Cats and the sub-pages of Cats all display a different menu.

    So far I have been able to limp along. My question for you is how to handle this situation with 3.0 Custom Menus… any ideas?

    1. Ryan
      Ryan October 26, 2010 at 10:41 am | | Reply

      Build your menus, then use http://codex.wordpress.org/Function_Reference/in_category

      if(in_category('dogs'){
      wp_nav_menu( array('menu' => 'dog menu' ));
      }
      if(in_category('cats){
      wp_nav_menu( array('menu' => 'cat menu' ))
      }
  150. Ryan
    Ryan October 26, 2010 at 10:31 am | | Reply

    The next step is to make menus keyboard accessible…

    It would be nice to make certain elements conditional.

  151. Francisco Valverde
    Francisco Valverde October 27, 2010 at 6:36 am | | Reply

    Great article! I would just to learn a bit more. I am developing a system of pages-subpages-’subsubpages’, that is a three level hierarchy, and I would like just to use three menu system: primary, secondary and tertiary. So the first menu will always appear. The second menu only when I am in a page with subpages, and the third menu when I am in a subpage with ‘subsubpages’. I am getting close but I would appretiate any help!

  152. ZigPress
    ZigPress October 28, 2010 at 4:46 am | | Reply

    Many thanks for this handy “everything in one place” reference. Much easier than sifting through four or more Codex pages! Bookmarked.

  153. Aga
    Aga November 2, 2010 at 7:03 am | | Reply

    Thank you, Justin, for the article. It helped me to get into the subject easily.

    Is there a way to get rid of the classes e.g.: id=”menu-item-47″ class=”menu-item menu-item-type-post_type menu-item-47″

    I use serveral menus on my page and just want to remove the code I don’t need.

  154. Daniel Tomasch
    Daniel Tomasch November 2, 2010 at 11:36 pm | | Reply

    @Justin,

    Excellent Article!

    I’ve got a stumper for you —

    On:

    http://www.diplomatswashington.com/view/wordpress/about

    I have several WP Nav Menus. They work just fine on pages and on single.php

    However, under:

    http://www.diplomatswashington.com/view/wordpress/category/events/advancedfocused-morning-programs

    All the menus disappear! They disapear under any archive.php or category.php page — but show up everywhere else. Any suggestions?

  155. Dimitar
    Dimitar November 19, 2010 at 6:05 pm | | Reply

    Wonderful, yeah, but what if I need to place an image (with or without a link behind it) to be my first (or whatever) item in the list?
    For example, I want my “Home” link to be an image and I need it to be marked as the current place (by CSS means) when I am there. Is it possible?

  156. Lily
    Lily December 15, 2010 at 7:57 pm | | Reply

    Hi, thanks for this article. But I need help!

    I don’t know what I’m doing wrong, but what I have showing up now is both the text menu and the images that I want to replace the text (but they’re not showing up fully).

    My question is, after registering and setting up my custom menu, do I still need to hard code it somewhere?

    I used the ‘class’ option (after reading that it was hidden in the screen options… thanks to those who pointed that out!) but the images aren’t replacing the text, they’re just overlapping.

    (sorry, I don’t know php and i’m still a n00b when it comes to coding)

    thanks!!

  157. sebastien
    sebastien December 16, 2010 at 9:42 am | | Reply

    i have a category “food” with category-children “patatoes”,”apple”,”bread” etc…
    I drag’n drop the item “food” in my menu. But i want that all the children appears too in my menu. Is it possible to display all the children in the menu ? (i don’t want drag’n drop all the children, because, for example, i have 150 000 children for this category)

  158. Jonathan
    Jonathan December 23, 2010 at 8:20 am | | Reply

    I need some help please, You seem to understand this widget this best… I’m not sure what I need to do to fix this problem.
    Problem: when viewing my blog as a visitor, you should be able to “drag & drop” the sidebar menu anyway you like it, in IE, Safari, or Opera no problems but in Firefox it doesn’t remember my preference from page click to page view – it used to, (had to reload Firefox 2 days ago) And in Chrome the menus won’t collapse at all and I’ve been trying to figure this one out for weeks… Am I missing some sort of plug-in support? Any help or response would be much appreciated.
    Jonathan

  159. jonathan
    jonathan December 23, 2010 at 9:21 am | | Reply

    Submitted earlier about custom menu drag & drop issues, – Resolved for Firefox it was the Google toolbar – 6 causing the problems went back to 5 no problems…

  160. Filipe Kiss
    Filipe Kiss January 5, 2011 at 11:30 am | | Reply

    Hey Justin,

    I was wondering… is there any way to ‘export’ to menu to recreate it programatically?

  161. thinkdj
    thinkdj January 10, 2011 at 5:49 am | | Reply

    Great tutorial. This is pretty much the only WP 3.0 menus tutorial online which covers the topic in this detail.

  162. DrSpectAcula
    DrSpectAcula January 11, 2011 at 6:00 am | | Reply

    using the wp_nav_menu… (excuse this is quite a mouthful)
    would it be possible to have the submenu class of the current-menu-parent not show on a :hover of another menu-list item?

    In other words, is it possible for css for step back a level and then affect a lower one.

    i.e. Hovering on any top level menu item overwrites the static submenu being shown (overwritten with the hovered menu item’s sub menu)

    e.g. ul#menu-main li.menu-item:hover [ some selector here to step back a level ] .current-menu-parent .sub-menu {display:none;}

  163. Teo Maragakis
    Teo Maragakis January 17, 2011 at 3:13 pm | | Reply

    Hi, one question. I am building a custom navigation menu which gets images related to the items, for example, if the menu consists of page entries, an icon (taken from a custom field in the page). Is this possible?

    To make it simpler, if I have a menu that includes pages, I want a loop to search in the text/metadata each menu entry. Is this possible?

    1. Christian Sisson
      Christian Sisson February 7, 2011 at 8:35 pm | | Reply

      Same question here: is it possible to show both post-image and excerpt on a menu? Anyone?

  164. John
    John January 30, 2011 at 9:23 pm | | Reply

    The question about having a second navigation menu hasn’t been answered yet? Hopefully, the answer wasn’t it being incomplete. I hope someone can shed some light as to how to create more than one menu.

    ps. I have tried all the examples and still no luck. the theme location stuff isn’t working. this is what I have in my functions,

    add_action( ‘init’, ‘register_my_menus’ );
    function register_my_menus() {
    register_nav_menus( array(
    ‘header-menu’ => __( ‘Header Menu’ ),
    ‘content-menu’ => __( ‘Content Menu’ ),
    ‘footer-menu’ => __( ‘Footer Menu’ )
    ));
    }

    and within the theme at different locations I would add, ‘header-menu’ ) ); ?> or ‘content-menu’ ) ); ?> or ‘footer-menu’ ) ); ?>. I am still not getting the menus I created in the backend to show up accordingly.

    Thanks.

  165. Vaseem Ansari
    Vaseem Ansari February 4, 2011 at 8:42 am | | Reply

    Hello Dear
    i read this post and tried few tricks, its really nice, but my problem is still unresolved.
    i have a query and i know that you know the answer of this
    i am using wp nav menu to show 6 navigation menu in header here
    http://showprojects.net/projects/csrc/

    Now i want when user clicks on any item(post,page,category,tag) in sub menu then the left sidebar will show all the submenus of that parent.

    My question is similar to this thread
    http://wordpress.stackexchange.com/questions/2802/display-a-only-a-portion-of-the-menu-tree-using-wp-nav-menu

    Explaination
    Root Menu
    Sub menu 1
    Sub menu 2 (clicked)

    My sidebar will show only child sub menus of clicked root menu
    Sub menu 1
    Sub menu 2 (clicked)

    Waiting for your answer.
    Thanks
    Vaseem Ansari

  166. Wade
    Wade February 16, 2011 at 3:42 pm | | Reply

    I know I am beating a dead horse here but thank you for this great tutorial! It saved me a ton of time adding menus to a wordpress theme I am creating.

  167. Phil Gwynne
    Phil Gwynne February 27, 2011 at 3:20 pm | | Reply

    Many thanks for this, just what I was after and more!

  168. Vale
    Vale March 7, 2011 at 9:05 pm | | Reply

    Great article.
    Is there a way to control (ie not include) also classes and ids of the ul, li and a elements generated in the menu?

  169. John
    John March 23, 2011 at 4:26 am | | Reply

    Great tutorial, thanks for this article.

  170. matt
    matt March 30, 2011 at 10:14 am | | Reply

    Hi everyone, I posted a similar question in a reply, but am going begin a fresh post to better explain my issue(s) in hopes that someone can (puhleeeeeease) shed some insight into my problem and hopefully (on my knees begging) that someone can help find a solution.

    When I create/save a menu (Appearance > Menus > Menu Name > Create Menu ) and select/save it from the dropdown menu (Appearance > Menus > Theme Locations > Save) I am unable to select or edit the menu when I leave and/or refresh the screen. The menu displays correctly on the website, but I can no longer edit, without creating a new menu and replacing it.

    Also, unsure if this is related (I’m guessing it might be) but when I create categories (Posts > Categories > Add New Category) they disappear when I leave and/or refresh the page, and do not show up as an option when creating a new post.

    I’ve only had these issue since installing Worpress 3.x. I’ve re-installed fresh twice (mac 10.6.6/xampp).

    Hopefully someone can help me, I’m at my wits end. Thanks again!

    1. matt
      matt April 5, 2011 at 8:10 am | | Reply

      Seems this may be a dead thread, but if anyone is having the same issue as I was experiencing, it was due to not having proper permissions setup on the /Applications/XAMPP/xamppfiles/etc/my.cnf


      open terminal and navigate to the folder with my.cnf
      type: sudo chmod 600 my.cnf

      hit enter then input your password. Restart mysql and you are good to go

      (big thanks to Dan!)
      ref; http://slopjong.de/2009/08/31/houston-i-cant-write-to-file/comment-page-1/#comment-13866

  171. grubbs
    grubbs April 8, 2011 at 5:09 am | | Reply

    Thanks for this exellent tutorial

  172. Luis Abarca
    Luis Abarca April 11, 2011 at 3:06 pm | | Reply

    Very helpful, thanks a lot !!

  173. Levani
    Levani April 26, 2011 at 10:27 am | | Reply

    Is it possible to wrap only top level menu items with some code? For example I want to wrap only top level menu items in tags… How can I determine whether the item is child or not…

  174. Levani
    Levani April 26, 2011 at 10:28 am | | Reply

    I meant span tags…

  175. Tim LeB
    Tim LeB May 6, 2011 at 1:32 pm | | Reply

    Hi guys,

    I want to use menus and read the entire article but i’m a total noob at that and I understand nothing at all..I have a theme that says ”doesn’t support native menu” but i’m trying to get this done and can’t figure it out, is there a plugin or something like that?

  176. Gordon
    Gordon May 6, 2011 at 2:15 pm | | Reply

    Hello,

    that was exactly what i was looking for. Just create a new design for my blog and tried to add a second menu. Wasn’t working until I found your article. Now it works. Very good description. Thanks for sharing your knowledge.

  177. André
    André May 9, 2011 at 10:21 am | |