Support » Themes and Templates » Multiple Loops and offset posts in Category Template

  • Resolved TheMarque

    (@themarque)


    Hello!

    I have searched for an answer to this topic but haven’t quite find the solution that solves all of them.

    I am working on (what I thought was) a simple category template. Everything I have tried has technically worked, but then messes something else up like the posts from what category or shows duplicate posts or messes up my pagination.

    What I want is a category page that shows one latest post at the top, and then the following 6 latest posts but stylized differently. The first post at the top will be a banner type image for the post and the bottom 6 will be tile like. I keep getting correctly want I want it to look like but it either a.) repeats the 1st latest post (offset doesnt seem to be working) or it b.) messes up my pagination or c.) it shows only the latest posts in general and not within the specific category.

    Here is my current code, any help is appreciated:
    http://pastebin.com/A9SkyJ2D

Viewing 9 replies - 1 through 9 (of 9 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    have you looked at the examples in http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action ?

    also possible with a single query and a conditional for the first post in the loop; something like described in my post here.

    the answer would depend on what you want to do on the ‘paged’ pages – show the top post different again?

    @alchymyth
    Thanks for the response.
    Yes I did look at the examples in that codex and I couldn’t get it to work exactly right.

    I don’t mind for the top image to show up on the ‘paged’ pages but I would rather it disappear altogether if possible.

    Is this possible to do with the tips on the link you gave me?

    Thanks

    Michael

    (@alchymyth)

    Forum Moderator

    should be possible:

    http://pastebin.com/5wL9P2zU

    you need to set dashboard – settings – reading to 7 posts per page for this example

    Absolutely perfect. Ten times easier than I thought it would be. Thanks for simplifying it.

    Question: If I wanted to add another loop later, say, a related posts list, would that interfer withe this code or could I just create another wp_query?

    Also, any idea as to why it only shows me 6 posts per page?

    Michael

    (@alchymyth)

    Forum Moderator

    just create another wp_query

    why it only shows me 6 posts per page

    what is your setting under dashboard – settings – reading – posts pages show at most..

    just create another wp_query

    Great, thanks!

    what is your setting under dashboard – settings – reading – posts pages show at most..

    That’s set at 10 but I usually try to override it, however, I dont have anything set on my category template, it’s just automatically showing 6.

    Nevermind! I had a plugin called “Custom Post Per Page” that was messing with it. Problem resolved.

    Wow! Thank you so much!

    Thank you @alchymyth for providing some amazing code. I was looking for this type of answer for days. You have saved me from some unneeded stress. : )

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Multiple Loops and offset posts in Category Template’ is closed to new replies.