Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom type, which uses custom taxonomy to create categories. I can add 'products' and assign them to the category structure that I have created.

There is a top level menu which displays the parent categories, clicking each takes the user into the category hierarchy.

If there are no products in any sub-category of a parent category, then that listitem shouldn't display in the top level nav.

If I set hide_empty=1 all the parent categories disappear, not just the one with no products. Can anyone advise?

share|improve this question
    
What function do you use to list products (custom taxonomy)? –  Mamaduka Aug 24 '11 at 13:43
    
get_terms() I tried pasting code in this comment but it came out looking scrambled! –  Richard Lane Aug 26 '11 at 11:29
    
Paste the code, then hit the {} button in the editor. Otherwise, you need a blank line before the codebit, and 4 (or more) spaces before each line of code to manually add it. –  Eric Holmes Jan 21 at 21:50
    
I also suggest using 'pad_counts' => true. This will allow empty top level terms to appear if child terms have items. –  Eric Holmes Jan 21 at 21:51
add comment

1 Answer

Try setting 'hierarchical' to true if its not already.

From source documentation:

  • hierarchical - Whether to include terms that have non-empty descendants
  • (even if 'hide_empty' is set to true).

I think its usually set to trie by default, so I'm thinking you might have intentionally set it to fale for your purposes.

share|improve this answer
    
I think you are right - thanks for the reminder. hierarchical should be true by default and I'm not setting it –  Richard Lane Aug 26 '11 at 11:34
add comment

Your Answer

 
discard

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.