Forums

No Documentation on Conditional Queries? (3 posts)

  1. gaberosser
    Member
    Posted 1 year ago #

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

    http://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?

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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(); ?>
  3. gaberosser
    Member
    Posted 1 year ago #

    Awesome. Thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic