WordPress custom menu disappear on home page when using custom post types and/or taxonomies.

Wordpress custom menu disappears on home page.

As you’re developing a theme, you try one of WordPress’s newer options: Custom Post Types.  Searching the internet you stumble upon Justin Tadlock’s blog.  You try his way of showing custom post types on your home page of your wordpress blog.  Then boom. You’re custom menu is not showing on your homepage.  Now what do you do.

I spent about a week going back and forth with my custom taxonomies, and WordPress 3.0’s new custom menu editor trying to figure out why the hell my home page isn’t showing my custom menu.  It shows all on my other pages.

Out of all the code, from all over the internet, that I used.  I had put the following code in my functions.php hoping to show my custom post types.

This code works, unless you’re using a custom menu you’ve made in the back end of wordpress.  This will for whatever reason (to which I have not investigated) make your custom menu’s disappear from your home page faster than a rabbit can crap.  So I’ve spent a whole week investigating my custom taxonomies, and wordpress’s custom menu editor, when the only thing I messed up was using Justin Tadlock’s code.

Here is what you do instead of putting that jargon of a excuse for code into your functions.php:

Pick any of your template files that show your posts or pages: pages, loop, home, index, or whatever single-{taxonomy name}.php you want to edit and add your custom post types to and add the following code above the loop:

or whatever you needs may be:

Happy coding, and careful who’s blog you read 😉 Thanks JustinTadlock I was stuck on that crap for a week.

~Steven Kohlmeyer

5 thoughts on “WordPress custom menu disappear on home page when using custom post types and/or taxonomies.”

  1. I cannot figure out how to get your solution to work, and Ihave the exact problem you describe. Where does your code go? I tried it in several places in loop.php in twentyten (and a child theme thereof) with no luck.

    All help greatly appreciated.

  2. Hi,

    I’ve been struggling for a while to understand why my menus were disappearing, before finding your post. It turned out I’d used similar filters in functions.php. Taking out the filters made everything work as expected!

    Great stuff, thanks for sharing 🙂

  3. After digging around the query object a bit, I found that there are is a “post_type” element in the query’s query_vars variable that changes from operation to operation depending on the purpose of the query being run. For the query that produces the custom menu, this query_post_type variable is set to ‘nav_menu_item’.

    Adding: ($query_post_type != ‘nav_menu_item’) to the condition of your post_type function should prevent nav menu queries from being overriden.

Leave a Reply