1

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?

4
  • What function do you use to list products (custom taxonomy)?
    – Mamaduka
    Commented Aug 24, 2011 at 13:43
  • get_terms() I tried pasting code in this comment but it came out looking scrambled! Commented Aug 26, 2011 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. Commented Jan 21, 2014 at 21:50
  • I also suggest using 'pad_counts' => true. This will allow empty top level terms to appear if child terms have items. Commented Jan 21, 2014 at 21:51

1 Answer 1

1

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.

1
  • I think you are right - thanks for the reminder. hierarchical should be true by default and I'm not setting it Commented Aug 26, 2011 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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