Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Sticky posts and multiple query loops

  • Hello,

    I have a problem with sticky posts and GB query loops (this is the page: https://www.assoplmilano.it/notizie/)

    I have 2 query loops on this page:

    The first one displays only ONE post that is the most recent sticky post and belongs to a specific category.

    The second query loop displays all posts (of a specific category, the same as above)

    My problem is that with this setup the newest sticky post is displayed twice (once per loop).

    I’d like to display the newest sticky post only once, in the first query loop.

    So, I’d like to find a way to remove from the second query loop ONLY the most recent sticky post (which is the one that is already displayed in the first loop. I don’t want to remove all sticky posts).

    Thanks a lot

  • Hi there,

    select the second Query Loop, and in the settings Add Parameter -> Sticky Posts and choose the Exclude option.

  • Hi David, thanks. However, this solution wouldn’t work because it would exclude all sticky posts (I need to exclude from the second query loop only the most recent, since it is the only one shown in the firs query loop).

    (For context: Posts are managed by my client: I could ask him to always remember to deselect the sticky option of an old post when a new sticky post is created, but I suspect he would forget most of the times. If I hide all sticky posts in the second loop, they wouldn’t be visible anywhere else, except for the most recent).

  • In the end I went for a different approach. It is a bit less elegant though, so I am still curious to know if there was a solution.

    Thanks1

  • In that case you would simple set the Sticky Post Paramter to Ignore.
    Then the second loop won’t add any sticky posts to the top of loop, and neither will it remove them from their natural place in the loop;

  • Great, thanks!

  • You’re welcome

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