Site logo

[Support request] Using the Query Loop Block for a single featured post

Home Forums Support [Support request] Using the Query Loop Block for a single featured post

Home Forums Support Using the Query Loop Block for a single featured post

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2301688
    Al

    On my homepage, I’m using 2 query loop blocks. The first one is meant to display just one post, and the second shows 12 posts. They are separated by some text so they have to be separate blocks.

    The second query is working fine. I have it set to offset by 1, 12 per page, no pagination. It shows exactly 12 as it should, regardless of sticky posts.

    The top one is meant to be a single featured post. I have it set to show 1 per page, no pagination. But it behaves differently than the other query loop. It’s ok if it’s only showing the most recent post. But if I have any posts set to sticky, it throws all of them in there, plus the most recent post. I have fiddled with the parameters to “only sticky” and “include sticky” and both function the same. Is there a way to limit this query to 1 and only 1 post, regardless of sticky settings?

    Oddly, it works perfectly when I’m editing the page. I can edit the sticky posts and reload the editor and it shows 1 correct post. It’s only when I’ve saved it and reloaded the real page that it shows all the sticky posts stacked together.

    Ideally, I want it set to display only sticky, because it looks like it falls back gracefully to the latest post if no sticky post is set.

    Thanks!

    #2301762
    David
    Staff
    Customer Support

    Hi there,

    can you make sure you have the latest versions of GB ( 1.5.4 ) / GB Pro ( 1.3.0 ) installed.

    In the latest versions Sticky Post parameter has the Ignore arg, select that on your first query loop, and it should ignore their stickiness.

    #2302416
    Al

    Hi David,
    Thanks for the reply. Yes I do – I see the option there. But I don’t want to ignore the sticky posts. In the featured spot, I want 1 post (only) to show. Either the latest sticky post, or if none are set, the most recent post.

    In the query showing 12 posts, it adheres to the “posts per page” setting regardless of whether it’s showing sticky posts or not. I don’t understand why the query with 1 post per page would act differently?

    I thought maybe it was caching because I can see it correctly in the editor, but even after purging everything it will still show infinite sticky posts in the top query where it should only show 1 total post.

    The easy answer obviously would be to make sure that only one post is set to sticky at any given time. Unfortunately this is a site with editors who will not always be paying attention to such things, so I have to code it so they can’t break it.

    If I have it set to show “only” sticky posts, it gets me most of the way there, it’s just the extra posts I can’t get rid of. Am I misunderstanding the intent of the “posts per page” setting and why it would behave differently with 2 different queries? Is there a different way I should go about this?

    #2302494
    Ying
    Staff
    Customer Support

    Hi Al,

    If you choose ignore the sticky posts, it will work as you expected.

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