Grow your CSS skills. Land your dream job.

WordPress Theme development: How to show category based post in home page?

  • # December 30, 2012 at 12:14 pm

    Suppose I have 3 categories (cat 1 , cat 2 , cat 3) , and my blog home page shows 6 recent posts . I want to show 2 recent posts from every category.

    Like

    cat 1 :

    Post 1

    Post 2

    cat 2:

    Post 1

    Post 2

    cat 3 :

    Post 1

    Post 2

    how can I do it ? Thanks in advance

    # December 30, 2012 at 12:16 pm

    You will probably need to run 3 separate query loops to do what you need, specifying the different categories and number of posts in each.

    # December 30, 2012 at 12:23 pm

    Thanks andy_unleash
    < ?php query_posts("posts_per_page=2"); ?>

    In the above code , where should put parameter for category , what modification I need to do .

    # December 30, 2012 at 1:11 pm

    Your best bet is to have a good read of the [Query Posts Codex](http://codex.wordpress.org/Function_Reference/query_posts)

    In particular the examples and parameters section – [parameters & categories etc](http://codex.wordpress.org/Function_Reference/query_posts#Examples)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".