207 responses to “Goodbye, headaches. Hello, menus!”

  1. Ryan

    Another excellent article as always! Thanks Justin :)

  2. Jean-Baptiste Jung

    Excellent post. Thanks!

  3. Michelle

    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

      “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

    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

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

  7. Andrew Nacin

    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

    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.

    1. Andrew Nacin
  9. Jeff Starr

    Superb!

    Incredible work once again, Justin :)

  10. Chris Creed

    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

    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.

  12. Sawyer

    Great overview, this will be very helpful!

  13. Justin Tadlock On Menus In WP 3.0

    [...] post online talking about the new menus feature in WordPress 3.0. The post title says it all. Goodbye, headaches. Hello, Menus!. As I have reviewed numerous commercial WordPress themes along with a few free ones, I’ve [...]

  14. Jeffro

    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

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

    thanks Justin

  16. Mike Smith

    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. Goodbye, headaches. Hello, menus! | WPLover

    [...] Goodbye, headaches. Hello, menus! [...]

  18. Kel

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

  19. Jörn

    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

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

  20. Goodbye, headaches. Hello, menus! « Blog do Gabriel

    [...] headaches. Hello, menus! junho 1st, 2010 | Category: Sem [...]

  21. Andrew

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

  22. Today in WordPress world – 01/06 | Links | WereWP

    [...] Goodbye, headaches. Hello, menus! Here is a great summary of all the new features now available with WordPress 3.0, by Justin Tadlock. (tags: menu wordpress tutorial development) Leave a Reply Click here to cancel reply. [...]

  23. Rilwis

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

  24. cehwitham

    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

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

      1. Global_1981

        Awesome thanks saved me a lot of frustration!

    2. Markgt

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

  25. cehwitham

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

    Many thanks.

  26. Justin has a nice theme developer orient… « WordPress Development Updates

    [...] Justin has a nice theme developer orient… Justin has a nice theme developer oriented review of the nav menus. [...]

  27. Jörn

    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.

  28. Template Changes/Tags for Wordpress 3.0

    [...] For More Details on Custom Menus, I suggest reading tutorial by Justin Tadlock. [...]

  29. kucrut

    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?

  30. Christian Zumbrunnen

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

  31. Carlos

    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.

  32. Arnoud

    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!

  33. Dr. Lawrence Kindo

    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.

  34. Webbhotell

    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.

  35. Steve

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

    1. James

      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

      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!

  36. Philip

    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!

  37. Webnews #12: Greek, Kiss, Tokyo & SEO | Andi Licious' Blogosphäre

    [...] Character-Illustrationen in Webseiten. Die Kalte Muschi und Produktnamen im Marketing. Menüs in WordPress 3. Die Chrome Developer Tools für den Google-Browser. Sagenhafte fast 10 Millionen Menschen aus [...]

  38. James

    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.

  39. Peter

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

  40. Kenneth Younger

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

  41. Daily Digest for June 5th

    [...] Shared Goodbye, headaches. Hello, menus!. [...]

  42. Kevinjohn Gallagher

    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

  43. WordPress 3.0 Features – Every Theme Developer Should Know

    [...] Goodbye, Headaches. Hello, Menus! [...]

  44. Hover

    Fantastic!

    Very much looking forward to WordPress 3.0!

  45. Best On WordPress From The Past Week N.9 » wpCanyon

    [...] Goodbye, headaches. Hello, menus! [...]

  46. Weekend Roundup #86

    [...] BloggingWordPressMicrosoft & WordPress – Good Work MS!Improving The WordPress Support ForumGoodbye, headaches. Hello, menus!A Sample WordPress Theme Options PageTechnologyChina aims to become supercomputer [...]

  47. Ads

    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.

  48. Ads

    Sorry, my previous post should have read…

    in my header.php i have:

    wp_nav_menu(array('theme_location' => 'global'));
  49. WordPress 3.0: What’s new - op111.net

    [...] Goodbye, headaches. Hello, menus! By Justin Tadlock [...]

  50. Where did the Spring Go? WP3, Menus & jQuery - TrinityDC Web Guy - Trinity Washington University

    [...] in the release candidate stage, and it has a menu system that I am eyeing. I’m excited about this tutorial on the menus system, but I’m still concerned that access to the menus feature is not available to authors (time to [...]

  51. Timothy

    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!

  52. Ed Nailor

    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

  53. Aurel Wong

    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

  54. Ed Nailor

    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!

  55. Johnnie

    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

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

      Im using a child theme of twenty ten.

  56. New Menu Navigation System in WordPress 3.0 | I'd Rather Be Writing - Tom Johnson

    [...] comprehensive post by Justin Tadlock, Goodbye, headaches. Hello, menus!, covers the new menu system in WordPress 3.0 in depth. I’ve been using the new menu system on [...]

  57. Mel

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

  58. Lonny

    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.

  59. Adam

    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

  60. Lox

    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.

  61. NightMan

    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

      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’.

  62. cristiana

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

  63. Benjamin Knight

    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!

  64. Johan

    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.

  65. Kyle

    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

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

  66. stephan

    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

  67. Wordpress 3.0 Roundup | Themergency

    [...] Goodbye, headaches. Hello, menus! – Justin Adlock Another awesome tut from Justin Adlock on the new menu system. Again, this is a must read! [...]

  68. WordPress 3.0 Theme Development Links | WPLover

    [...] Goodbye, headaches. Hello, menus! [...]

  69. Leo

    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?

  70. Cancasa

    Can’t wait until I start using this enhancement.

  71. Govindji Patel

    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.

  72. Around the WordPress Community: June 18th, 2010 | WordCast - WordPress podcast, Blogging podcast, Blogging news, WordPress plugins, WordPress themes, WordPress news

    [...] WordPress 2.9. Here is a tutorial on how to include them with the rest of the newly thumbed posts.Goodbye, headaches. Hello, menus! – Justin Tadlock – Justin breaks down the details in the new customizable menu system in WordPress 3.0, [...]

  73. links for 2010-06-18 (Jarrett House North)

    [...] Goodbye, headaches. Hello, menus! WordPress 3.0 allows themes to create custom navigation menus. (tags: wordpress css) [...]

  74. Josh

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

  75. How to add support for navigation menus to your WordPress theme

    [...] Informative article on nav menus by Justin Tadlock Ramblings [...]

  76. Practical Theme Support For WordPress 3.0 Menus

    [...] I’m not going to delve into all the different options you can use when adding support for menus. There are enough articles out there that cover this in depth: I highly recommend you read Justin Tadlock’s excellent Goodbye, headaches. Hello, menus!. [...]

  77. Troy

    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

  78. Troy

    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!

  79. Dave Immerz

    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

      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.

  80. Darrell

    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.

  81. William Lindley

    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.

  82. Riccardo

    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?

  83. Jose Random

    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.

  84. Maria

    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 :)

  85. Whiskeyjim

    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.

  86. HOW TO: Get Up-to-Date on WordPress 3.0

    [...] Padilla has a great tutorial for how to create menus that have customize labels and images.Justin Tadlock covers how to implement custom menus into your themes and gives some styling tips and [...]

  87. Vincent Klaiber

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

  88. Dennis Winter

    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

  89. Stephen Cronin

    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.

  90. scriptygoddess » Blog Archive » New WordPress 3.0 Navigation Menus – What you need to know to get started

    [...] more so I could have found it when I was working on this recently – but there's some additional reading here on how to set all this up (it's a lot more in depth than I got into – I guess my version is the "Cliff [...]

  91. Web Solutions and Design - Asteriskr

    [...] proud of this addition. There’s a great guide to utilising the Wordpress 3 Custom Menus on Justin Tadlock’s blog. Check it [...]

  92. My Six Favorite New Features in WordPress 3.0 « The Smorgasbord of Douglas Bell

    [...] actually found that it wasn’t too difficult to add custom menu support to my existing themes using this tutorial. All you have to do is add a few lines of code to the theme’s functions.php file in order to [...]

  93. Angelia

    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

      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

  94. Jasmine Soona

    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 :)

  95. Avio karte

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

  96. Barrett Golding

    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

      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

        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)

  97. Anthony

    How can I use superfish with nav_menu ?

  98. Benjamin Knight

    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.

  99. New Website Design « Pages From My Head

    [...] pages, categories, etc, can all be dragged and dropped around to create a menu hierarchy. And it is incredibly easy to code in to a [...]

  100. 10 of the Best Tutorials to Get You Up to Speed With WordPress 3.0

    [...] Goodbye. headaches. Hello, menus! [...]

  101. KC

    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.

  102. marcelo araujo

    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!

  103. gabsy

    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 ?

  104. Will Barker

    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

  105. ge fanuc series

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

  106. Christopher

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

  107. Agus Suhanto

    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

      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.

  108. Karl B

    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

  109. Yunus

    Thanks for your good works.

  110. Gabriel Tadeu

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

  111. mati

    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)

  112. mati

    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)

  113. WordPress 3.0 Overview – notes | WordPress Austin
  114. mati
  115. Nikesh

    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

  116. martin

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

  117. Matt

    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?

  118. matt

    @Barrett Golding

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

    cheers!

    1. Kevinjohn Gallagher

      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 :)

  119. Jennifer

    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. :-)

  120. Debbie Campbell

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

  121. Pakblogger

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

  122. Add WordPress 3.0 Navigation System to Your Site | I'd Rather Be Writing

    [...] an excellent description of the new navigation template tag, see Goodbye, headaches, Hello, menus! from Justin [...]

  123. Jason

    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?

  124. Mrmist

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

  125. Rem

    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.

  126. Benjamin Knight

    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.

  127. Roelof

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

  128. Jennifer R

    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 :(

  129. How to update your theme with WordPress 3.0 navigation menu | WP Journo | WordPress & Journalism

    [...] Tadlock has a thorough post on how to integrate this functionality in all sorts of creative ways. But it may be too confusing [...]

  130. Leland

    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

      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.

  131. kamal

    ONE Word : I LOVE YOU ;)

    ___________
    (Yeah it’s 3)

  132. Frank Anthony

    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

      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'
  133. Thesis Should Become the New Default WordPress Theme Options Page

    [...] [...]

  134. Robin Anderson

    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

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

  135. Aj

    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?

  136. Ryan

    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

      Ouch.. *informative

  137. WordPress 3.0 – The Ultimate Roundup For Developers & Users | KreativeThemes.com

    [...] you updating your theme in order for it to work with these menu management.WordPress 3.0 Menu UpdateGoodbye, headaches. Hello, menus!Making Themes Ready for WordPress 3.0 MenusAdding Backwards Compatible WordPress Menus To Your [...]

  138. dallas

    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.

  139. Davit

    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?

  140. Duy

    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

  141. Matt Edminster

    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?

  142. Eric Boyer

    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.

  143. JeremyT.

    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…:)

  144. hnla

    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.

  145. alsd

    ‘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

  146. rowland

    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.

  147. Rob Watson

    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.

  148. Rob Watson

    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

  149. tudor

    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.

  150. Rob Watson

    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?

  151. Paul

    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!

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.