First, a nice picture of what we can achieve with this theme and wpsolr !
What is this theme about ?
This very documentation is built with this theme. It’a a general purpose theme, with some specific post types to generate documentation and knowledge base articles.
Where can I find it ?
Copy the manual child theme
The manual theme .zip files contain a folder named “manual-child”. Copy it to your WordPress themes folder, and rename it as you like.
Hide the search bar target post types
We do not need them anymore, as we will replace them by our facets widget.
Use the theme customizer, section “search->Target Post types”:
Manual Post types
First, in the indexed data menu, select the manual post types you want to index. They will appear in the facets widget. Here, we selected the manual documentation, faq, and knowledge base.
Now, in the facets menu, select the manual post types, and give them a decent label. Below, we show how we renamed the post type “Manual_kb” in “Knowledge Base”.
Now, the search results appear with our manual post types facets (after positioning the WPSOLR facets widget):
Taxonomies
First, in the indexed data menu, select the manual taxonomies you want to index. They will appear in the facets widget. Here, we selected the faq categories, portfolio categories, documentation categories, knowledge base categories, and knowledge base tags.
Now, in the facets menu, select the manual taxonomies, and give them a decent label. Below, we show how we renamed the taxonomy “Manualdocumentationcategory” in “User guide category”.
Now, the search results appear with our manual taxonomies facets (after positioning the WPSOLR facets widget):
Custom fields
First, in the indexed data menu, select the manual custom fields you want to index. They will appear in the sort list widget. Here, we selected the manual post views, and the manual documentation votes. Select a sortable type for both of them, here “Integer”.
Now, in the sort list menu, select the manual custom fields, and give them a decent label. Below, we show how we renamed custom field “Manual_post_visitors descending” to “Most viewed”.
Now, the search results appear with our manual sort facets (after positioning the WPSOLR sort list widget):
Position the wpsolr widgets
Drag&Drop our Widget in the primary area, which is defined by the manual search page template.
Search results
In the manual theme, search results appear without an excerpt. But we want the nice excerpts generated by WPSOLR, containing keywords highlighting, no ?
To do that, we copied the file content-search.php form the manual theme folder to our own child folder, then added the get_excerpt() function:
<?php ... <?php the_title( sprintf( '<h2><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?> <!-- wpsolr add excerpt result --> <p> <?php the_excerpt(); ?> </p> ...
And the results now with the customised search template (notice the keywords bolded):