1

let's say I have a main query and it displays posts from Movies and Music categories. I want the query to show always 5 latest posts from Movies and 5 latest posts from Music category. When I create a new post in Movies category the query will show 6 posts From Movies and 4 posts from Music category. But I need a way to show always 5 latest posts from each categories on homepage.

In other words, I still want the regular query where posts are ordered by date and not categorized but want to limit the number of posts per category displayed on homepage. I found some solutions to display latest post/posts from each categories but all those solutions categorizes posts. I still want the regular wp query.

Here are two solutions: http://eisabainyo.net/weblog/2010/03/10/display-5-latest-posts-in-each-category-in-wordpress/

First post of each category

As you can see posts are categorized and are not in regular order. When there is a new post it will not be at the top and will go under its own category. I really googled for hours, tried many solutions but none of them does what I want.

UPDATE: This question was marked as duplicate however I tried the mentioned answer and realized it's not what I'm looking for. I already found similar solutions but they all categorize posts. e.g.

First Movie Post - Second Movie Post - Third Movie Post

(then) First Mucis Post - Second Mucis Post - Third Mucis Post

Posts should be displayed as if it's a regular wp query where posts are displayed by date no matter which category they belong. But each category should be limited by 5 posts. So the mentioned answer is close but not exactly what I'm looking for. Sorry for my terrible English.

  • Could you not just run two queries, one for each category and limit the results with posts_per_page? – MBL Mar 19 '14 at 17:21
  • Actually I have 5 categories and will filter them using jquery. Seperate queries is not a solution for me. – Carlisle Holm Mar 19 '14 at 17:55
  • @CarlisleHolm I posted an answer that solve your problem in the question that your question was marked as duplicate of. See wordpress.stackexchange.com/a/138537/35541 – gmazzap Mar 19 '14 at 20:37
  • G. M., Your solution is exactly what I'm looking for and works PERFECTLY! Thank you very much. – Carlisle Holm Mar 20 '14 at 8:06
  • possible duplicate of How to get posts from two categories with WP_Query? – Pieter Goosen Nov 4 '14 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.