I have create custom post(book). In which i have five texonomy categories: CatA, CatB, CatC, CatD, CatE. & i want to show only 3 posts and i want that these posts coming from CatA, CatC, CatD.(One post each these categories.)
<?php
$args = array(
'post_type' => 'book',
'posts_per_page' => '3',
$terms = get_terms( array(
'taxonomy' => 'categories',
'field' => 'name',
'terms' => array('CatA', 'CatB', 'CatC')
))
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) { ?>
<?php while ( $query->have_posts() ) { $query->the_post(); ?>
<div style="background-image:url('<?php echo get_the_post_thumbnail_url(''`enter code here`);?>')">
</div>
<?php the_title();?>
<?php } // end while ?>
<?php } wp_reset_postdata(); ?>