Display only the latest post from multiple categories

I have a jQuery slider at the top of my index.php, which works fine. The only problem is that I would like to use query_posts to only display the latest post from five different categories, and always show one from each.

So when a new post is created in, lets say the category interview, this will be displayed. But the interview post which was posted one day earlier will then not be displayed, but the latest post from the four other categories are still there.

Read More

I think this is a bit complicated, no?

Related posts

Leave a Reply

1 comment

  1. i think you’d have to use get_posts 5 different times. what about this:

    global $post;
    $posts = array();
    
    //categories you want to pull latest posts from;
    $cats = (1,2,3,4,5);
    
    foreach($cats as $cat):
    $args = array( 'numberposts' => 1, 'category' => $cat ); 
    $posts[] = get_posts($args);
    endforeach;
    
    if($posts): ?>
    <ul>
    <?php foreach( $posts as $post ) :  setup_postdata($post); ?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    

    i totally didn’t test this, but I think it might work