Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

How do I add individual custom post type posts to a navigation menu in WordPress?

I've just completed the Bootstrap to WordPress course and was interested in the Walker class for the navigation so I could add dropdowns to my menu. I have a demo site which I'm creating which is for a cafe. I have created a custom post type for 'Our Drinks' and have a main page displaying the drinks (similar to the Portfolio in the videos) which currently shows about 6 drinks which, when you click on the thumbnail, opens that individual drinks details.

I want to be able to create a menu so users don't have to go to the 'Our Drinks' page first, they can simply point to 'Our Drinks', the menu will drop down and then display the drinks which can then be selected:

Our Drinks

  • Mocha
  • Latte
  • Flat White

I have seen on the Advanced Custom Fields documentation that you can add a 'Page_Link' field which will then display the link in a dropdown when editing the post but I don't seem to be able to use this information anywhere in the menu's screen in the admin area.

I have two issues at the moment: 1) when I add sub items to my 'Our Drinks' menu, they are not displaying (presumably because there is a link on the 'Our Drinks' item already?) 2) the custom post type posts aren't displaying anywhere in the menus admin area for selection.

Clearly I'm missing something, somewhere. If you guys need to see some code to see what's what, let me know and I'll add it in.

Hope someone can help me.

Many thanks.

1 Answer

Try adding 'show_in_nav_menus' => true, to your custom post type

if you donΒ΄t see it as an option after adding this code, check the Screen options to make sure the correct box is checked.