Displaying posts in suggestions template as promoted posts

  • markus
    Participant
    # 1 year, 4 months ago

    Hi,

    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!

    markus
    Participant
    # 1 year, 4 months ago

    Any ideas how this could be done?

    wpsolr
    Keymaster
    # 1 year, 4 months ago

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

You must be logged in to reply to this topic.