[Support request] Query loop and ensuring a single sticky post is being shown

Home Forums Support [Support request] Query loop and ensuring a single sticky post is being shown

Home Forums Support Query loop and ensuring a single sticky post is being shown

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2351279
    Joy

    Hi GP team,

    On our home page, I’ve added a query loop at the top of the page (based on the “image at left” query pattern block) and would like this to show a single sticky post (so whatever the most recently published post that has been designated as a sticky post). In the display settings, I’ve selected “items per page” as 1 and “max pages to show” as 1. I’ve published, cleared cache etc, but it’s still showing multiple sticky posts instead of just 1. I’ve tested this on a brand new page and it works fine so I’m not sure why it’s showing multiple posts on the home page.

    Would you be able to suggest anything to try here?

    Many thanks in advance!

    #2351282
    Fernando
    Customer Support

    Hi Joy,

    This issue will be addressed in the upcoming update. For now, can you try adding sticky-loop to the class list of the Grid Block inside the Query loop? Then, add this PHP:

    add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
        if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'sticky-loop' ) !== false ) {
            $query_args['ignore_sticky_posts'] = true;
        }
    
        return $query_args;
    }, 10, 2 );

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    The Alternative would be to download the current release candidate versions in https://generateblocks.com/account/

    #2351405
    Joy

    Many thanks Fernando – do you know roughly when the next update will be ready?

    #2351411
    Fernando
    Customer Support

    You’re welcome Joy! The upcoming update has already passed the alpha and beta testing, and is already in the Release Candidate category. It should be anytime soon.

    #2351415
    Joy

    Ok perfect, I think I’ll wait it out. Much appreciated!

    #2353534
    Fernando
    Customer Support

    You’re welcome Joy!

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