get_posts('numberposts=5&category=93+85')get_posts('numberposts=5&category=9385')
Is there a way to have get_posts grab only posts that are in BOTH categories, as above?
Use WP_Query
's category__and
:
$args = array(
'posts_per_page' => 5,
'category__and' => array( 93, 85 )
);
$my_query = new WP_Query( $args );
while( $my_query->have_posts() ):
$my_query->the_post();
the_title();
endwhile;
wp_reset_postdata();
<?php global $post; $myposts = get_posts('numberposts=5&category=30'); foreach($myposts as $post) : setup_postdata($post); ?> <?php if ( in_category('1') ) { ?> <?php include('sidebar-reviews_review.php'); ?> <?php } ?>
To make it pull posts from categories 30 and 1.