2

I have custom query that shows specific number of posts from specific categories/tax. Currently I limited the query to show posts from 2 categories , 3 and 4.
Issue I have is that the query can be limited to number of posts for example 4 than the query displays first 4 posts from category 3 never showing posts from category 4.

$args = array (
    'posts_per_page' => '4',
    'post__in' => array(),
    'post__not_in' => array(807),
    'author__in' => array(),
    'post_type' => array('post'),
    'paged' => 1,
    'tax_query' => array (
        'relation' => 'OR',
        array (
            'taxonomy' => 'category',
            'field' => 'term_id',
            'terms' => array(3,4),
        )
    ),
    'order' => 'DESC',
    'orderby' => 'date',
    'ignore_sticky_posts' => true,
    'date_query' => array(),
);

$query  = new WP_Query( $args );

How can I display specific number of posts from specific categories and show minimum one item from assigned categories?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.