recent posts
// WP_Query arguments
$args = array(
'post_type' => array( 'post' ),
'post_status' => array( 'publish' ),
'nopaging' => true,
'posts_per_page' => '8',
'order' => 'DESC',
'orderby' => 'date',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'terms' => 'test',
'field' => 'slug',
'operator' => 'IN',
'include_children' => true,
),
),
);
// The Query
$recent_posts = new WP_Query( $args );
// The Loop
if ( $recent_posts->have_posts() ) {
while ( $recent_posts->have_posts() ) {
$recent_posts->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();