Search code examples
wordpresspostcategories

Getting posts from categories array


I have some certain categories' ids. I want to loop this categories and last 3 posts in one time. I try this but only come one category from array.

<?php
    $args = array(
    'cat'      => 48,43,49,46,47,44,51,50,42,
    'order'    => 'ASC',
    'showposts' => 3
        );
query_posts($args);
?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>

Solution

  • This piece of code won't work: 'cat' => 48,43,49,46,47,44,51,50,42,

    You'll have to use an array 'cat' => array(48,43,49,46,47,44,51,50,42),