if ( have_posts() ) { while ( have_posts() ) : the_post(); // Your loop code endwhile; } else { echo 'Sorry, no posts were found'; } ?>