Support » Fixing WordPress » How can I display two posts per category on the home page?

  • Resolved Greeny106


    Hello, I have been bashing my head against a wall now for around three hours. All I want to do is display two posts for each category, by the following category order (Featured Plus > Featured > Standard) or by ID (4, 3, 1).

    I tried several plugins but none of them worked as needed, I tried using query_posts functions to display the posts, but you can’t seem to order by category how I would like…

    So, my last resort is seeking help here.

    Thanks in advance, any help would be appreciated,
    Tom Green.

Viewing 4 replies - 1 through 4 (of 4 total)
  • MichaelH


    foreach( array(4, 3, 1) as $cat_id ) {
        'cat' => $cat_id,
        'post_type' => 'post',
        'post_status' => 'publish',
        'posts_per_page' => 2,
        'caller_get_posts'=> 1
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        echo 'List of Posts for category '. $cat_id;
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        //the_content();  //or the_excerpt{};
    wp_reset_query();  // Restore global post data stomped by the_post().


    Brilliant! Thank you so much, works like a charm, just styled it into the previous code and it looks exactly as it should!

    Thank you again, greatly appreciated!

    Hello…I’m interested in the same thing but not in any category order. Right now, it’s showing all the latest posts from all categories in chronological order with the most recent first…

    And I’d like to instead have the latest two from each category show up on the homepage still in chronological order for all categories.

    Help please?



    Forum Moderator

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can I display two posts per category on the home page?’ is closed to new replies.