Documentation

Everything you need to get started with Blocksy Theme and Companion

Modify the Related Posts queries

In some cases, you might wish to modify the criteria on how the Related Posts module pulls in its posts. We have created two example filters, which accept standard WordPress queries. These help you modify the criteria on how Related Posts are pulled in.

blocksy:related-posts:query-args

This filter computes query arguments, such as sorting options.

add_filter('blocksy:related-posts:query-args', function ($args) {
    $args['order'] = 'DESC';
    // Other custom args

    return $args;
});

blocksy:related-posts:query

This filter modifies the logic completely and lets you make advanced posts pulls in accordance to your rules.

add_filter('blocksy:related-posts:query', function ($query) {
    global $post;

    return new WP_Query([
        // Logic for computing the related based on the current post...
        'posts_per_page' => 5,
    ]);
});
Not the solution you are looking for?

Please check other articles or open a support ticket.