WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show posts by category at the home (3 posts)

  1. roxer82
    Member
    Posted 3 years ago #

    Hello,

    My blog has got 3 big categories and I would like to show just 3 post of them at my home grouped by the categories. So the home would look like this:

    CATEGORY 1
    Last Post 1
    Last Post 2
    Last Post 3

    CATEGORY 2
    Last Post 1
    Last Post 2
    Last Post 3

    CATEGORY 3
    Last Post 1
    Last Post 2
    Last Post 3

    I have got other small categories but I just want to show the 3 biggest.

    I found that it can be done using Multiple Loops (http://codex.wordpress.org/The_Loop) but I couldn't make it work.

    Does anybody know how to do it?
    Thanks!

  2. Runtheball
    Member
    Posted 3 years ago #

    Try something like this...

    <?php query_posts('cat=1&posts_per_page=3');
       if (have_posts()) : while (have_posts()) : the_post();
         the_content();
         endwhile;
       endif; ?>
    
    <?php query_posts('cat=2&posts_per_page=3');
       if (have_posts()) : while (have_posts()) : the_post();
         the_content();
         endwhile;
       endif; ?>
    
    <?php query_posts('cat=3&posts_per_page=3');
         if (have_posts()) : while (have_posts()) : the_post();
           the_content();
         endwhile;
       endif; ?>

    That should get you very close.

  3. roxer82
    Member
    Posted 3 years ago #

    Thank you very much eisenbart!
    It works :-)

Topic Closed

This topic has been closed to new replies.

About this Topic