Theming of search results

  • Stefan
    Participant
    7 months, 3 weeks ago #35853

    I am still evaluating the plugin. Search is working but i am struggling with styling the search result.
    I use ‘use current theme search template with ajax. I render a searchfield in a template with get_search_form();
    I created a template for each search result. But in that template I only have access to the WordPress Post data. But I do not want to show the post excerpt but the excerpt from the SOLR-result (so with the search-term highlighted.) Is there a way to access this from a template?

    wpsolr
    Keymaster
    7 months, 3 weeks ago #35854

    Nothing to do. Title and description of WP_Posts returned by WPSOLR are already highlighted with keywords. Use them in your template loop.

    wpsolr
    Keymaster
    7 months, 3 weeks ago #35855

    I forgot to mention that only titles are highlighted for WooCommerce results.

    Stefan
    Participant
    7 months, 3 weeks ago #35856

    In case my question is not clearly formulated, or this is the wrong way to get to the required result:
    what i am trying to achieve, is a way to:
    1. Add a search form to a template file that uses SOLR
    2. Be able to style the results, preferably by using a WordPress template. But if it is only possible by using a twig template, that’s fine as well. An example of how to override result.twig would be appreciated.

    wpsolr
    Keymaster
    7 months, 3 weeks ago #35857

    WPSOLR replaces the query on all archives. Use your own archive WordPress template to show WPSOLR results:
    https://codex.wordpress.org/Creating_a_Search_Page

    The template shortcode delivered by WPSOLR is deprecated.

    Stefan
    Participant
    7 months, 3 weeks ago #35858

    In my template that i use inside the loop, i use get_the_excerpt() and there is no highlighting there.
    Also if i change it to get_the_content(), there is no highlighting.

    The query is set up like this:
    $search_query = ‘something’;
    $query = new WP_Query(array(
    ‘s’ => $search_query,
    ));

    wpsolr
    Keymaster
    7 months, 3 weeks ago #35859

    And with the title?

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.