Custom Loop with certain number of one category

Question

I have a custom loop that goes like this:

            global $post;
            $tmp_post = $post;
            $args = array( 
            'numberposts' => '120',
            'orderby' => 'date',
            'order'   => 'DESC',
            'cat' => array(1,2,7,8,9,27, 30, 31),
            'tax_query' => array(
                        array(
                            'taxonomy' => 'post_format',
                            'field' => 'slug',
                            'terms' => array( 'post-format-aside','post-format-video' ),
                            'operator' => 'NOT IN',
                        ),
                    )        
 );
            $myposts = get_posts( $args );
            foreach( $myposts as $post ) : setup_postdata($post); 
        ?>

What I need is not a output of 120 posts in total, but 120 posts only of the category with the ID 2. Is that possible?

Thanks

0
rabo 2 months 0 Answers 5 views 0

Leave an answer