Argument to retrieve Posts via WP_Query() and display them in a loop
by Joseph on the 23rd Apr 2015
<?php
// listing all services
$args = array(
'post_type' => 'post', // get from posts
'posts_per_page'=>6, // set the maximum number of posts
);
$the_query = new WP_Query( $args );
<?php if ( $the_query->have_posts() ) { ?>
<!-- pagination here -->
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php endwhile; ?>
<?php wp_reset_postdata();
?>
<?php }else{ ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php } ?>