WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multiple Loops and offset posts in Category Template (10 posts)

  1. TheMarque
    Member
    Posted 2 years ago #

    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

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    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?

  3. TheMarque
    Member
    Posted 2 years ago #

    @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

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    should be possible:

    http://pastebin.com/5wL9P2zU

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

  5. TheMarque
    Member
    Posted 2 years ago #

    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?

  6. TheMarque
    Member
    Posted 2 years ago #

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

  7. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    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..

  8. TheMarque
    Member
    Posted 2 years ago #

    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.

  9. TheMarque
    Member
    Posted 2 years ago #

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

    Wow! Thank you so much!

  10. stowepro
    Member
    Posted 1 year ago #

    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. : )

Topic Closed

This topic has been closed to new replies.

About this Topic