0

I need to display the number of categories which I can do with this...

<?php echo $num_cats  = wp_count_terms('category'); ?>

...but I only want it to count categories that have at least one post.

Thanks in advance.

0

Have you tried:

wp_count_terms( 'category', array( 'hide_empty' => TRUE ) );

You can check out the source here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy