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
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