2 Most recent posts
// WP_Query arguments
$args = array(
'post_type' => array( 'post' ),
'post_status' => array( 'publish' ),
'posts_per_page' => '1',
'tax_query' => array(
array(
'taxonomy' => 'category',
'terms' => 'featured',
'field' => 'slug',
'operator' => 'IN',
),
),
);
// The Query
$postsquery = new WP_Query( $args );
// The Loop
if ( $postsquery->have_posts() ) {
while ( $postsquery->have_posts() ) {
$postsquery->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();