Title: Relevanssi not functioning
Last modified: April 21, 2018

---

# Relevanssi not functioning

 *  Resolved [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/)
 * I’ve used the free version of Relevanssi for a year or more with no problems 
   at all. Then I had to change my woocommerce theme (old one discontinued) to Storefront
   with a child them. Relevanssi does not function. Only woocommerce product search
   is working.
    I’ve been trying to fix the query in search.php but no luck. Maybe
   I’m not doing it right. Also checked for plugin interference. I’ve included the
   search.php. Maybe someone could check it out and give me some help and directions.
   [Storefront search.php](https://pastebin.com/8YiJ8519)
 * Thanks
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Frelevanssi-not-functioning%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10206082)
 * No problems with the search results template, it looks perfectly normal.
 * Do you have a complete index? Can you show me screenshots of your Relevanssi 
   indexing and searching setting pages, please?
 *  Thread Starter [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10206112)
 * Hey Mikko,
    Thanks for responding.
 * [Index](http://i.share.pho.to/30157e67_o.png)
 * [Search](http://i.share.pho.to/53b7998c_o.png)
 * Try these.
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10207889)
 * Everything seems good there.
 * Please do the first two steps as described on [this Relevanssi KB page](https://www.relevanssi.com/knowledge-base/debugging-relevanssi-searching-issues/).
   What kind of results you get?
 *  Thread Starter [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10209985)
 * Ok Mikko,
    I did the the two steps, nothing jumps out as being wrong but then,
   I’m not sure what i’m looking at. So I just pasted them in –
 * This is the search results from “Look at the parameters Relevanssi is getting”
 * array(71) { [“s”]=> string(15) “Hospital sheets” [“post_type”]=> string(7) “product”[“
   error”]=> string(0) “” [“m”]=> string(0) “” [“p”]=> int(0) [“post_parent”]=> 
   string(0) “” [“subpost”]=> string(0) “” [“subpost_id”]=> string(0) “” [“attachment”]
   => string(0) “” [“attachment_id”]=> int(0) [“name”]=> string(0) “” [“static”]
   => string(0) “” [“pagename”]=> string(0) “” [“page_id”]=> int(0) [“second”]=>
   string(0) “” [“minute”]=> string(0) “” [“hour”]=> string(0) “” [“day”]=> int(
   0) [“monthnum”]=> int(0) [“year”]=> int(0) [“w”]=> int(0) [“category_name”]=>
   string(0) “” [“tag”]=> string(0) “” [“cat”]=> string(0) “” [“tag_id”]=> string(
   0) “” [“author”]=> string(0) “” [“author_name”]=> string(0) “” [“feed”]=> string(
   0) “” [“tb”]=> string(0) “” [“paged”]=> int(0) [“meta_key”]=> string(0) “” [“
   meta_value”]=> string(0) “” [“preview”]=> string(0) “” [“sentence”]=> string(
   0) “” [“title”]=> string(0) “” [“fields”]=> string(0) “” [“menu_order”]=> string(
   0) “” [“embed”]=> string(0) “” [“category__in”]=> array(0) { } [“category__not_in”]
   => array(0) { } [“category__and”]=> array(0) { } [“post__in”]=> array(0) { } [“
   post__not_in”]=> array(0) { } [“post_name__in”]=> array(0) { } [“tag__in”]=> 
   array(0) { } [“tag__not_in”]=> array(0) { } [“tag__and”]=> array(0) { } [“tag_slug__in”]
   => array(0) { } [“tag_slug__and”]=> array(0) { } [“post_parent__in”]=> array(
   0) { } [“post_parent__not_in”]=> array(0) { } [“author__in”]=> array(0) { } [“
   author__not_in”]=> array(0) { } [“orderby”]=> string(9) “relevance” [“order”]
   => string(4) “DESC” [“meta_query”]=> array(0) { } [“tax_query”]=> array(2) { [“
   relation”]=> string(3) “AND” [0]=> array(4) { [“taxonomy”]=> string(18) “product_visibility”[“
   field”]=> string(16) “term_taxonomy_id” [“terms”]=> array(1) { [0]=> int(1418)}[“
   operator”]=> string(6) “NOT IN” } } [“wc_query”]=> string(13) “product_query”[“
   posts_per_page”]=> int(24) [“ignore_sticky_posts”]=> bool(false) [“suppress_filters”]
   => bool(false) [“cache_results”]=> bool(false) [“update_post_term_cache”]=> bool(
   true) [“lazy_load_term_meta”]=> bool(true) [“update_post_meta_cache”]=> bool(
   true) [“nopaging”]=> bool(false) [“comments_per_page”]=> string(2) “50” [“no_found_rows”]
   => bool(false) [“search_terms_count”]=> int(2) [“search_terms”]=> array(2) { [
   0]=> string(8) “Hospital” [1]=> string(6) “sheets” } [“search_orderby_title”]
   => array(2) { [0]=> string(168) “wrd_posts.post_title LIKE ‘{7a79222a4ef29dd29e2141ffc9afea18f84b04677bd6e665beeea14e482cb3bd}
   Hospital{7a79222a4ef29dd29e2141ffc9afea18f84b04677bd6e665beeea14e482cb3bd}'” [
   1]=> string(166) “wrd_posts.post_title LIKE ‘{7a79222a4ef29dd29e2141ffc9afea18f84b04677bd6e665beeea14e482cb3bd}
   sheets{7a79222a4ef29dd29e2141ffc9afea18f84b04677bd6e665beeea14e482cb3bd}'” } }
 * Search results from MySQL query
 * string(667) “SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title *
   8 + relevanssi.content * 2 + relevanssi.comment * 0.75 + relevanssi.tag * 1 +
   relevanssi.link * 0 + relevanssi.author + relevanssi.category * 1 + relevanssi.
   excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn
   AS tf FROM wrd_relevanssi AS relevanssi WHERE relevanssi.term = ‘choosing’ AND
   relevanssi.doc NOT IN (SELECT DISTINCT(tr.object_id) FROM wrd_term_relationships
   AS tr WHERE tr.term_taxonomy_id IN (1418)) AND ( relevanssi.doc IN ( SELECT DISTINCT(
   posts.ID) FROM wrd_posts AS posts WHERE posts.post_type IN (‘product’) ) )”
 * And the third steo – “Look at the results” –
 * array(5) { [1056]=> float(182.003433521) [1221]=> float(91.0017167605) [1292]
   => float(91.0017167605) [1337]=> float(91.0017167605) [7484]=> float(91.0017167605)}
 * What do you see? Any errors? Something missing? Anything wrong?
    Suggestions?
 * I do appreciate you time,
    Greg
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10211740)
 * There’s nothing unusual there, indeed, just the typical WooCommerce product visibility
   filter being added. The search is also restricted to just products, as is usual
   for WooCommerce.
 * The search also seems to find results now. Is Relevanssi still active? Are the
   any particular searches that are not producing results as expected?
 *  Thread Starter [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10211783)
 * Relevanssi is active.
    I’m wanting to get posts results. Example: when searching
   for “How to choose a wheelchair” , which we have numerous articles, when get 
   products.
 * It seems something is blocking relevanssi. It’s active but not showing up in 
   results.
 *  Thread Starter [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10211933)
 * “The search is also restricted to just products, as is usual for WooCommerce.”
   
   This perhaps is the problem. I do not want woocommerce to restrict searches to
   products. I’d like to include posts and pages.
 * I checked the added code to the functions.php
 * add_filter( ‘relevanssi_modify_wp_query’, ‘rlv_force_post_product’ );
    function
   rlv_force_post_product( $query ) { $query->query_vars[‘post_types’] = ‘post,product’;
   return $query; }
 * It looks just like above
 * Can’t help but feel I’m missing something – :o(
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10212162)
 * Your theme search form includes this:
 * `<input type="hidden" name="post_type" value="product">`
 * That sets the post type restriction.
 * You can definitely get non-product results out of Relevanssi if you remove the
   post type restriction, like this: [https://www.caregiver-aid.com/?s=wheelchair](https://www.caregiver-aid.com/?s=wheelchair)
 * The code you have is correct, but since your non-product posts are not posts,
   but pages, it needs to look like this:
 *     ```
       add_filter( 'relevanssi_modify_wp_query', 'rlv_force_post_product' );
       function rlv_force_post_product( $query ) {
           $query->query_vars['post_types'] = 'page,product';
           return $query;
       }
       ```
   
 * Do note that your theme search results template depends on the post type setting;
   if you remove the product post type setting, you’re not seeing the product results
   template anymore, and the results will look like this: [https://www.caregiver-aid.com/?s=oximeter](https://www.caregiver-aid.com/?s=oximeter)
 * That’s common with WooCommerce themes.
 *  Thread Starter [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10215742)
 * Mikko,
    Sorry to be such a pain,.. but I’m still not there. I think the problem
   maybe in the Storefront theme.
 * Let me explain.
 * I used the code you gave me from your last comment, and I tested my site.
    (I
   have Storefront theme and Pharmacy child theme, both from Woothemes)
 * I tested the search results with the code installed and uninstalled, one at a
   time, in Storefront and then in the child theme. Never in both places at once.
 * There was never any change in the search results, with or with-out code.
 * Then – I went to appearance > themes. Did a live preview of Twenty Fourteen theme
   and got good search results. Both products and posts displayed, with-out adding
   the code.
 * My problem must be in Storefront theme, preventing posts and products together
   in on search result. Probably blocking Relevanssi.
 * I’m thinking I may need to hire some help to achieve the desired results, my 
   skills are somewhat limited. Thank you for your patience.
 * Do you have ideas or advice?
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10216293)
 * Here’s a code that makes WooCommerce search form not include the post type restriction:
 *     ```
       add_filter( 'get_product_search_form', 'rlv_remove_post_type_restriction' );
       function rlv_remove_post_type_restriction( $form ) {
       	$form = str_replace( '<input type="hidden" name="post_type" value="product" />', '', $form );
       	return $form;
       }
       ```
   
 * That might help too.
 * The problem is indeed related to your theme and WooCommerce. Storefront uses 
   the WooCommerce product search form, which includes the post_type restriction.
   The filtering function I gave you should fix it and remove the post type restriction;
   if it doesn’t, I’m not sure why.
 * However, there’s no reason why Storefront can’t show all post types in the search
   results: [https://www.caregiver-aid.com/?s=wheelchair](https://www.caregiver-aid.com/?s=wheelchair)
   is a search from your site with all post types included.
 * But yeah, hiring a developer may be a good idea, as that search results template
   is not very pretty for a mix of products and other pages. Any skilled theme developer
   should be able to help you sort this out.
 *  Thread Starter [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * (@mrfitz)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10219003)
 * Hey Mikko,
    That last code you gave worked great. I’ve got some tweaking to do
   but I like what I’m seeing.
 * Thank you so much for your help!
 * Greg

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Relevanssi not functioning’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [Mr.Fitz](https://wordpress.org/support/users/mrfitz/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/relevanssi-not-functioning/#post-10219003)
 * Status: resolved