I've got a page (page, not post) that near the bottom of the page I want to get the most recent 15 posts from a set of categories. I'm new to doing this and thought I was doing it correctly. The div (.article-item) repeats out 15 times as expected, but none of the specific post info is coming through.


   $catIDs = array(2,4,5,6,7,16);

   $args = array(
   'numberposts'     => 15,
   'category__in'    => $catIDs,
   'orderby'         => 'post_date',
   'order'           => 'DESC',
   'post_status'     => 'publish' );

   $posts_array = get_posts( $args );


<div class="left-side">
   <div class="article-grid group">
      <?php foreach ($posts_array as $postd): ?>

      <div class="col2 article-item <?php echo $postd->name; ?>-article">
         <div class="article-item-content">
               <span class="category">
                  <?php echo $postd->name; ?>:

            <h2><?php echo the_title(); ?></h2>
            <div class="article-link">
               <a href="<?php get_the_permalink(); ?>">READ MORE</a>
      </div><!-- /.article-item -->

      <?php endforeach; ?>
</div><!-- /.article-grid -->

As you can see, I've tried grabbing things off of the array (postd->name;) as well as the get_the_whatever type functions. I'm think it has to do with the fact that I'm in a page template, rather than a post/post template, but am a little over my head. Any ideas or help would be greatly appreciated.

1 Answer 1


I use the following for multiple post types, just replace foo and bar with your own post types:

$args = array(
            'post_type' => array( 'foo', 'bar' ),
            'orderby'         => 'post_date',
            // other parameters as needed

    $q = new WP_Query( $args );

    if ($q->have_posts()) : while ($q->have_posts()) : $q->the_post(); 
    // do stuff


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.