0

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.

2
  • What does the code that generates the menus look like?
    – Pat J
    Commented May 14, 2013 at 1:04
  • Its a child theme built on Genesis Commented May 14, 2013 at 4:02

1 Answer 1

0

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.

3
  • I just don't understand how to put this is a custom function Commented May 14, 2013 at 4:03
  • what is this plugin or whatever you are using for displaying those menus?
    – CBeTJlu4ok
    Commented May 14, 2013 at 4:06
  • no plugin. Its the default Genesis menu which uses the WordPress menu. Commented May 14, 2013 at 16:07

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.