Displaying posts in suggestions template as promoted posts

  • markus
    3 years, 3 months ago #24997


    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?

    Thank you!

    3 years, 3 months ago #25132

    Any ideas how this could be done?

    3 years, 3 months ago #25133

    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 3 years, 3 months ago by wpsolr.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.