$5
Query posts only if in BOTH categories
Normally, I use this to query posts in specific categories:
but I need to query posts only if they are in BOTH of these categories categories.
<?php $recent = new WP_Query("cat=6,38&showposts=0"); while($recent->have_posts()) : $recent->the_post();?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<?php endwhile; ?>
but I need to query posts only if they are in BOTH of these categories categories.
Meredith Marsh | 01/07/10 at 7:53pm
| Edit
(2) Possible Answers Submitted...
-

Last edited:
01/07/10
8:07pm -

Last edited:
01/07/10
8:31pmUtkarsh Kukreti says:Use this
<?php $recent = new WP_Query(array('category__and' => array(6, 38))); while($recent->have_posts()) : $recent->the_post();?>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<?php endwhile; ?>
This question has expired.
Current status of this question: Completed




