Which search templates are available ?

1042 views October 5, 2016 December 14, 2016 admin 1

With wpsolr, you can choose between two templates to display your search results.

 

Wpsolr search template

This is the template delivered by wpsolr. It is an Ajax template, and shows all the features in a custom search page, thanks to the wpsolr’s shortcode.

This template displays all the wpsolr features:

  • A search box with live suggestions
  • A sort list
  • Facets to filter results
  • A header showing the number of results
  • A “Did you mean ?” section to suggest alternative searches when the current search is empty
  • A pagination bar or an infinite scrolling javascript to navigate through all the results pages

The template is not customisable, all you can do is deactivate the wpsolr’s stylesheet and create your own to adapt its look&feel.

 

My theme search template

Your theme comes with its own WordPress search template. It probably contains features that you want to keep, but you’d also like to benefit from wpsolr’s features. For instance, your WooCommerce theme’s search results are presented with a “Add to basket” button, can show discounts, and so on.

Good news: you can use wpsolr with your own theme’s search template.

Here is how it works:

  • Your visitor submits a search
  • Your theme redirects the visitor to a search url containing ?s= (standard search url for WordPress)
  • wpsolr intercepts the search parameters, calls Apache Solr, and returns back the results formatted as post types
  • WordPress calls your themes search template (a php file), which loops on the results posts to display the search UI

Your theme search template is working as usual, you do not have to change it in any way.

But what are the wpsolr features you can count on then ?

  • A search box with live suggestions
    You can setup wpsolr to add live suggestions (keyword suggestions, or product suggestions) to your own search boxe(s). Just tell wpsolr the jQuery selectors (classes, ids …) of your search boxe(s).For instance, if your search box code is

    <input type="text" placeholder="Powered by WPSOLR ! Have a question? Ask or enter a search" value="" name="s" id="s" class="form-control header-search" autocomplete="off">
    

    then your jQuery selector to add suggestions to the search bow could be

  • A sort list.
    Add the WPSOLR sort list widget to your search page
  • Facets to filter results
    Add the WPSOLR facets widget to your search page
  • A header showing the number of results
    Not available.
  • A “Did you mean ?” section to suggest alternative searches when the current search is empty
    Not available.
  • A pagination bar or an infinite scrolling javascript to navigate through all the results pages
    The pagination bar is your theme’s. The infinite scrolling is not available.
Tags:

Was this helpful?

Leave A Comment
*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.