• I am using the following code snippet to query some custom posts:

    https://pastebin.com/dDqVpd9r

    I am wondering, it seems like it should be simple to provide a response if there are no posts, using WP’s Conditional Tags, but I just don’t know how to implement this. Something like

    “Sorry, there are no posts.”

    Could someone help, or point me in the right direction?

Viewing 2 replies - 1 through 2 (of 2 total)
  • you can add an ‘else’ section to your conditional code:

    if( $my_query->have_posts() ) {

    the ‘else’ section would be here:

    <?php endwhile; } else { ?>
    "Sorry, there are no posts."
    <?php } wp_reset_query(); ?>
    Thread Starter gaberosser

    (@gaberosser)

    Awesome. Thanks so much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No Documentation on Conditional Queries?’ is closed to new replies.