Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1467334

    I have a page that is displaying my blog posts. I am using the Blog Post page builder element on the Grid setting.

    in short, my client would like to occasionally use the “sticky post” setting. Please see: https://preucil.org/news/

    On this page, there is a post “2024 Suzuki String Retreat” that is designated as sticky. That post was made on September 16, 2024. Later a post was made on September 17, 2024. This new post is NOT sticky, but it shifted the sticky post down in the order. I would like to have the sticky post actually hold in the top left position in the grid.
    Thank you.

    —bbasler

    #1467414

    Hey William,

    Thank you for the inquiry.

    There is no option for this by default but you can add this filter in the functions.php file to place the sticky posts at the beginning of the query.

    add_filter("avia_post_slide_query", function($query, $params) {
        $sticky_posts = get_option('sticky_posts');
        $include = [];
    
        $args = [
            'taxonomy' => $params['taxonomy'],
            'post__not_in' => $sticky_posts,
            'fields' => 'ids',
        ];
        $posts = get_posts($args);
    
        $include = array_merge($sticky_posts, $posts);
        $include = array_map('intval', $include);
    
        $query['post__in'] = $include;
        $query['orderby'] = 'post__in';
    
        return $query;
    }, 10, 2);
    

    Best regards,
    Ismael

    #1467512

    Hey!

    UPDATE: We noticed that the code above is using the filter for the Masonry element instead of the avia_post_slide_query filter. We adjusted the filter a bit.

    Cheers!
    Ismael

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