I have WordPress set to display 5 posts per page, which is what I want. However, I'm now starting to use the new post formats (link, status, quote etc.) but I would these to not be counted towards the 5 posts per page. So how can I make the loop display the last x posts until it hits 5 standard posts?
1 Answer
As per comment trying to do this in one action will probably cause unholy pagination issues.
It might be easier to limit main query to normal posts, query posts with formats separately (depending on what you have in normal posts by date) and mix two sets together on display.
-
This is essentially what I was going to suggest: exclude the post-format Posts from the Primary Loop, so that they are excluded from Loop output and in the pagination. Then, query the post-format Posts using a secondary loop, and output them however appropriate. Oct 11, 2011 at 22:28
-
That would be perfect yes. I understand the exclude part for the main loop with the standard posts but I'm not sure how to set up the second loop and then mix it together to be displayed in chronological order. Any pointers would be most welcome.– JosOct 12, 2011 at 8:28
-
@Jos basic idea would be to retrieve two sets of posts as arrays, put those array together (sorted by date) and loop through resulting set. That is mostly a lot of PHP rather than WP functionality.– RarstOct 12, 2011 at 8:59