WordPress.org

Ready to get started?Download WordPress

Forums

Limit posts per category in query_posts? (8 posts)

  1. earthtojeremy
    Member
    Posted 3 years ago #

    How do I limit the number of posts per category in query_posts? Here is my current code:

    query_posts("cat=19,18,7&paged=$page&posts_per_page=$posts");

    Right now it displays all posts from each specified category, chronologically. I want it to show only the latest posts from each category. Setting posts_per_page doesn't work as it displays the latest X posts regardless of category (ex. if I set it to 3, and the latest 3 posts happen to all be from category 19, then it shows those 3 posts from cat 19 and none from the other assigned categories.)

    Is there such thing as posts_per_cat or something similar?

  2. Reuben Gunday
    Member
    Posted 3 years ago #

  3. earthtojeremy
    Member
    Posted 3 years ago #

    Same problem as described above. If you set posts_per_page to X, it shows X number of posts regardless of category. So if the latest X posts all happen to be from category 19, then all it displays are posts from cat 19, not the latest posts from each cat.

  4. earthtojeremy
    Member
    Posted 3 years ago #

    Anyone have any ideas?

  5. RachelNabors
    Member
    Posted 3 years ago #

    I'm having the same issue. I have another way of achieving what I want, but unfortunately, I NEED that query_posts for pagination.

    Any help?

  6. brisimmons105
    Member
    Posted 3 years ago #

    I'm wondering if anyone found a solution to this?
    Having the same issue here.

  7. photocurio
    Member
    Posted 3 years ago #

    I'm also interested in this. Anyone know how to do it?

  8. digibucc
    Member
    Posted 3 years ago #

    me too.... come on smart people!

Topic Closed

This topic has been closed to new replies.

About this Topic