0

I want to display all categories including the ones with no posts assigned to it.

So I found out about the 'hide_empty' property. Here is my code:

<?php 
    $args = array(
        'taxonomy' => 'category',
        'hide_empty' => false
    );
    foreach( get_terms( $args ) as $category ) {
        echo '<p>' . $category->name . '</p>';
    }
 ?>

But still only the non-empty categories are shown. What am I missing? My WP version is 4.8.

Thanks for help!

1
  • Are you sure you don't have a plugin that filters your query?
    – Laxmana
    Sep 4, 2017 at 10:22

1 Answer 1

0

Thanks to Laxmana's comment above I found the solution. The plugin User Access Manager has a setting in its options to hide empty categories. It is enabled by default. I disabled the option and now all categories are shown.

Thank you for your help, especially thanks to Laxmana!

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.