Site logo

Home Forums Support Offset

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2438184
    H

    Hi,

    On my homepage, I have a top section that shows the latest post from any category (1 post), then four other sections that show four posts from a specific category. How do I offset the first post from the top section, so it doesn’t show on the other sections?

    Thank you.

    #2438211
    Fernando
    Customer Support

    Hi HJ,

    You’re Homepage uses Query Loop Blocks to show posts.

    You can add a Parameter to Exclude that specific Post on other Query Loops to ensure it doesn’t show. Example: https://share.getcloudapp.com/Apue8k6W

    If you’re referring to something else, let us know.

    #2440176
    H

    Hi Fernando,

    I’ve tried the parameter (offset 1) to exclude the first post, but there’s a problem. Everything works fine if the featured post is in the same category as the section where I want to offset the post. Otherwise, it will remove the last post from the section, regardless the featured post is in the same category.

    For example, let’s say my featured post is in the category “Eat”; the offset 1 parameter will work well for my “Eat” section.

    On the other hand, if a post from the “Drink” category becomes my featured post, now the offset 1 parameter in the “Eat” section will still remove the most recent post in that section, which becomes a problem.

    I’m not trying to exclude a specific post from a query loop. It’s kind of conditional, if the featured post falls in the same category, offset that post, so it doesn’t show. If it belongs to a different category, do nothing.

    I hope I make sense.

    Thank you.

    #2440613
    David
    Staff
    Customer Support

    Hi there,

    it requires some PHP – see my reply here:

    https://generatepress.com/forums/topic/how-to-build-homepage-sections-with-posts-from-certain-categories/#post-2421392

    You will need to change the 'posts_per_page' => 5, to 'posts_per_page' => 1,

    #2443341
    H

    Hi David,

    You saved the day. Thanks for your help. The code worked great.

    #2444255
    David
    Staff
    Customer Support

    Glad to be of help!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.