I am trying to gets posts of specific categories.
$args = array( array(‘category__and’ => array(9, 7)) );
$acc_post = query_posts( $args );
foreach( $acc_post as $post ) : ?>
<?php the_title(); ?>
<?php endforeach; ?>
In the above code, I want to loop in through posts with category ID 9 AND 7.
But the output returns all the posts irrespective of category. Am I doing something wrong?
- The topic ‘Getting posts of a specifc category’ is closed to new replies.