$args = array(); $query = new WP_Query( $args ); if ( $query->have_posts() ) { // Have posts before loop while ( $query->have_posts() ) { $query->the_post(); // Loop Output } // Have posts after loop } else { // Nothing here :( } wp_reset_postdata();