I wonder if there is a way to display posts in autocomplete suggestions that are not related to used search keyword? I want to display those posts for promotional purposes at the top of the suggestions results and therefore I should be able to do a separate WP query for those posts before displaying anything in the suggestions template.
So, can I somehow add some extra posts to autocomplete suggestions that can be used by the suggestions twig template?
You can use the hook WPSOLR_Events::WPSOLR_ACTION_BEFORE_RENDER_TEMPLATE to replace the whole Twig template, or just its data.
// Somewhere in WPSOLR code
$template = apply_filters( WPSOLR_Events::WPSOLR_ACTION_BEFORE_RENDER_TEMPLATE, [
'template_path' => $template_name_with_extension, // this is the Twig file path
'template_data' => $args // This is the data
] );
This reply was modified 2 years, 6 months ago by wpsolr.