• Howdy! I know similar questions have been answered here and elsewhere, but I can’t find something that a) deals EXACTLY with my problem or b) I can understand as a noob in PHP code and the structure of the loop. So, apart from any answers, I’d also like to understand the “logic” behind them. Here it goes…

    I’m designing my own personal site where I want to have three main sections in its front page: Featured posts (possibly in a slider), (Quick) News and, after those, the rest of Posts.

    I know that you can run multiple loops in a page, and that this slows the page down. I saw some examples in “filtering out” a category of posts from the rest of posts, but not TWO categories. So, that’s actually my problem.

    To ask the question as a… well, real question: is it possible to have ONE loop that:

    1. Runs through the posts, “pulls” 4 posts in the “featured” category and displays them…

    2. …returns to the beginning, excludes the four already displayed “Featured” posts and pulls, say, 10 posts from the “News” category…

    3. …returns ONCE MORE to the beginning, excludes everything up to then and displays the rest of the posts, all of them, in a third section?

    I must repeat, I _know_ that there is information and I found tutorials for doing it, but I’ve also found OTHER information and tutorials nullifying what I’ve read by saying “it’s not optimal quering the database many times, it’s possible to just filter the results you’ve already got from your loop” – but they give examples for only ONE “featured category” and then “the rest of posts”, so that’s where I get lost. I’m asking for the OPTIMAL way to do it (or, if there’s something like that, “the OFFICIAL way of doing it”) – and, if it’s possible, with even MORE categories, as needed when designing “magazine style” themes.

    I should note that I’d also like the ability to have pagination in each of those categories but, if not possible, at least in the “main”, last part, with “the rest of posts”.

    Thanks for any advice and help.

    UPDATE:
    I should also add that I _DON’T_ want the posts to be mixed in one section and just “add a class” to them according to their category so as to style them differently. The page will be split in three different sections, so I guess it’s not easy just “styling them differently” – there would have to be three separate “groups” of posts, “featured”, “news” and “rest”.

  • The topic ‘Optimal Loop for two categories rest of posts’ is closed to new replies.