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 would like to hide a large number of categories from both the primary and secondary menus which have already been create however don't as yet contain posts.

Any PHP code i can use for this as there's a large number of categories.

share|improve this question
    
What does the code that generates the menus look like? –  Pat J May 14 '13 at 1:04
    
Its a child theme built on Genesis –  Brad Dalton May 14 '13 at 4:02

1 Answer 1

It depends which function you are using for querying those categories, but all of them has hide_empty argument

for example for:

<?php
     get_terms( $taxonomies, $args );
     $taxonomies = array( 
        'post_tag',
        'my_tax',
     );
     $args = array(
         'hide_empty'    => true, 
     ); 
?>

get_terms

by default, hide_empty argument is empty so check if it's false in you code.

share|improve this answer
    
I just don't understand how to put this is a custom function –  Brad Dalton May 14 '13 at 4:03
    
what is this plugin or whatever you are using for displaying those menus? –  CBeTJlu4ok May 14 '13 at 4:06
    
no plugin. Its the default Genesis menu which uses the WordPress menu. –  Brad Dalton May 14 '13 at 16:07

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.