Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Latest 4 posts

// WP_Query arguments
$args = array(
	'post_type'              => array( 'post' ),
	'post_status'            => array( 'publish' ),
	'posts_per_page'         => '4',
	'order'                  => 'DESC',
	'orderby'                => 'date',
);

// The Query
$latest_posts = new WP_Query( $args );

// The Loop
if ( $latest_posts->have_posts() ) {
	while ( $latest_posts->have_posts() ) {
		$latest_posts->the_post();
		// do something
	}
} else {
	// no posts found
}

// Restore original Post Data
wp_reset_postdata();