WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a custom taxonomy as category and display it by wp_nav_menu. The problem is, so far there are some terms in the custom taxonomy has no post attached to it, but it still show in the menu. So when people click on the menu link, they will got to a Nothing Found page.

How do I display the menu/term that only has post in it in wp_nav_menu?

share|improve this question
If you've tried some code already (even if it doesn't work, but is logical) add it to your question. – its_me Jul 1 '12 at 16:10
nope, i just add <?php wp_nav_menu( array( 'menu' => 'custom_tax', 'menu_class' => '', 'container' => 'catmenu','items_wrap' => '%3$s') ); ?> in my theme,I couldn't found any hook for this. – dev-jim Jul 1 '12 at 16:16
up vote 0 down vote accepted

Okay, I figure it out.

Instead of using wp_nav_menu, I use wp_list_categories which has more parameters that we can control. So to not display empty menu, I use:

<?php  wp_list_categories(array('taxonomy' => 'custom_tax','hide_empty' => '1','title_li' => '')); ?>

the hide_empty do the magic here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.