• On a client site I am using get_categories to list the categories and also display the number of posts inside each category.

    For some reason it’s also displaying categories that have no published posts inside them, but are not empty. Which means: categories with only drafts in them are also getting displayed.

    Ofcourse this shouldn’t happen, because those posts are drafts for a reason and visitors get a ‘No posts found’ message when they click on the categories with only drafts inside them.

    I couldn’t find anything about this in the doc’s, nor in the forums. Is there a way to exclude those categories from being listed?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Are you using the default parameters for get_categories?

    do they have subcategories with posts in them? I think that will cause the count to think there are posts where there are any in the parent categories.

    By default, get_categories hides empty categories, and there is something definitely wrong if drafts, or private posts, are getting counted.

    Thread Starter Hiranthi

    (@illutic)

    I’m using pretty much the default parameters, yes. As I said I couldn’t find anything about the drafts related to the parameters.

    The categories – with only drafts in them – that are getting displayed are subcategories.

    Thread Starter Hiranthi

    (@illutic)

    I’ve just been told (twitter) this is a common problem (the function calls all cats instead of only those with published posts).

    I’m having the same problem, has anyone got any solution?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘get_categories includes categories with drafts’ is closed to new replies.