{"id":25436,"date":"2016-09-11T11:29:13","date_gmt":"2016-09-11T10:29:13","guid":{"rendered":"https:\/\/www.megamenu.com\/?post_type=ht_kb&#038;p=25436"},"modified":"2019-11-12T11:20:13","modified_gmt":"2019-11-12T11:20:13","slug":"search-box-filters","status":"publish","type":"ht_kb","link":"https:\/\/www.megamenu.com\/documentation\/search-box-filters\/","title":{"rendered":"Search Box Filters"},"content":{"rendered":"<p>The <a href=\"https:\/\/www.megamenu.com\/documentation\/search-box\/\">search box<\/a> in Max Mega Menu Pro will use the standard WordPress search. It is possible to modify the behaviour of the search box using filters built into Max Mega Menu Pro.<\/p>\n<h3>Restricting results to WooCommerce Products<\/h3>\n<p><strong>Update:<\/strong>\u00a0Since publishing\u00a0this article we have introduced a checkbox option to the Search Replacement and Search Toggle block to restrict search results to WooCommerce Products. The code below is no longer required.<\/p>\n<p>If you are using the WooCommerce, the following code will alter the search box so that results are displayed\u00a0using the WooCommerce search results template.\u00a0This code should be added to your themes functions.php file:<\/p>\n<pre class=\"lang:default decode:true\">function mmm_restrict_search_to_products($html) {\r\n\treturn $html . \"&lt;input type='hidden' name='post_type' value='product' \/&gt;\";\r\n}\r\nadd_filter('megamenu_search_inputs', 'mmm_restrict_search_to_products');<\/pre>\n<h3>Restricting results to Heroic Knowledge Base Articles<\/h3>\n<p>If you are using the Heroic Knowledge Base plugin, the following code will alter the search box so that search results are restricted\u00a0Knowledge Base Articles. This code should be added to your themes functions.php file:<\/p>\n<pre class=\"lang:default decode:true \">function mmm_add_ht_kb_search($html) {\r\n\treturn $html . \"&lt;input type='hidden' name='ht-kb-search' value='1' \/&gt;\";\r\n}\r\nadd_filter('megamenu_search_inputs', 'mmm_add_ht_kb_search');<\/pre>\n<h3>Changing the search variable from &#8220;?s=&#8221; to &#8220;?gsc=&#8221;<\/h3>\n<p>Max Mega Menu uses the default &#8216;s&#8217; variable\u00a0to perform the search. If you are using plugin that uses a different parameter you can use the filter below to change it.\u00a0This code should be added to your themes functions.php file:<\/p>\n<pre class=\"lang:default decode:true\">function mmm_search_var($var) {\r\n    return 'gsc';\r\n}\r\nadd_filter('megamenu_search_var', 'mmm_search_var');<\/pre>\n<h3>Changing the search path from &#8220;\/?s=&#8221; to &#8220;\/search\/?s=&#8221;<\/h3>\n<p>Max Mega Menu uses the default root path to perform searches. If you are using a different page to display results you can use the filter below to change it.\u00a0This code should be added to your themes functions.php file:<\/p>\n<pre class=\"lang:default decode:true\">function mmm_search_action($action) {\r\n    return $action . 'search\/';\r\n}\r\nadd_filter('megamenu_search_action', 'mmm_search_action');<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The search box in Max Mega Menu Pro will use the standard WordPress search. It is possible to modify the behaviour of the search box using filters built into Max Mega Menu Pro. Restricting results to WooCommerce Products Update:\u00a0Since publishing\u00a0this article we have introduced a checkbox option to the Search&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"ht-kb-category":[14],"ht-kb-tag":[],"class_list":["post-25436","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-faqs"],"uagb_featured_image_src":[],"uagb_author_info":{"display_name":"Tom Hemsley","author_link":"https:\/\/www.megamenu.com\/author\/megamenu\/"},"uagb_comment_info":0,"uagb_excerpt":"The search box in Max Mega Menu Pro will use the standard WordPress search. It is possible to modify the behaviour of the search box using filters built into Max Mega Menu Pro. Restricting results to WooCommerce Products Update:\u00a0Since publishing\u00a0this article we have introduced a checkbox option to the Search...","_links":{"self":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/25436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/comments?post=25436"}],"version-history":[{"count":7,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/25436\/revisions"}],"predecessor-version":[{"id":25438,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/25436\/revisions\/25438"}],"wp:attachment":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/media?parent=25436"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-category?post=25436"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-tag?post=25436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}