• Hi there,

    I need to hide my taxonomy-filter when there are no posts in the current taxonomy the user is viewing.

    So, I’m looking for some kind of if/else-statement to achieve this.

    Can anybody help, please?

    Thanks! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • So basically, you want to check if there are 0 posts on in a given page?
    If so, this will probably work:

    global $wp_query;
    if($wp_query->post_count == 0)
    {
       //there are no posts
    }

    Thread Starter tibitabo

    (@tibitabo)

    Thanks, this seems to be working! ??

    Is this option recommendable performance-wise? I’m pretty new to WordPress, so I don’t know about best practices yet.

    Thanks again!
    Heiko

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide sidebar if there are no posts in taxonomy’ is closed to new replies.