{"id":9233000,"date":"2017-06-15T22:59:39","date_gmt":"2017-06-15T22:59:39","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/conflict-with-wp-ultimate-recipe-search-widget\/"},"modified":"2017-06-15T22:59:39","modified_gmt":"2017-06-15T22:59:39","slug":"conflict-with-wp-ultimate-recipe-search-widget","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/conflict-with-wp-ultimate-recipe-search-widget\/","title":{"rendered":"Conflict with WP Ultimate Recipe search widget"},"content":{"rendered":"<p>I&#8217;m using both WP Ultimate Recipe and Search Everything plugins, and everything was OK until recently when I discovered that the detailed search widget in WPUR, was systematically sending empty results back. Investigating further, I determined that the problem disappeared when deactivating Search Everything.<\/p>\n<p>I looked into the code for the WPUR widget, and it basically uses the &#8216;pre_get_posts&#8217; hook to modify the query based on the different values of searched taxonomies that were set using the widget, and retrieved from the url thanks to a GET method.<\/p>\n<p>I joined the callback&#8217;s code below.<\/p>\n<p>Do you see a possible workaround on your side for this kind of issue ? Would it be possible for the plugin to recognize that it&#8217;s a &#8220;custom&#8221; search query, and in this case don&#8217;t activate itself ? <\/p>\n<p>Or would there be a better solution on WPUR plugin side ? <\/p>\n<p>Regards,<\/p>\n<p>Pascal.<\/p>\n<p>    public function pre_get_posts_search( $query )<br \/>\n    {<br \/>\n        if( $query-&gt;is_search &amp;&amp; isset( $_GET[&#8216;wpurp-search&#8217;] ) )<br \/>\n        {<br \/>\n            \/\/ Only search for recipes<br \/>\n            $query-&gt;set( &#8216;post_type&#8217;, &#8216;recipe&#8217; );<\/p>\n<p>            \/\/ Check taxonomy filters<br \/>\n            $tax_query = array();<br \/>\n            foreach( $_GET as $tag =&gt; $term )<br \/>\n            {<br \/>\n                if( substr( $tag, 0, 7 ) == &#8216;recipe-&#8216; &amp;&amp; $term != &#8216;0&#8217;) {<br \/>\n                    $tax_query[] = array(<br \/>\n                        &#8216;taxonomy&#8217; =&gt; substr( $tag, 7 ),<br \/>\n                        &#8216;field&#8217; =&gt; &#8216;id&#8217;,<br \/>\n                        &#8216;terms&#8217; =&gt; array( intval( $term ) ),<br \/>\n                    );<br \/>\n                }<br \/>\n            }<br \/>\n            if( !empty( $tax_query ) ) {<br \/>\n                $query-&gt;tax_query-&gt;queries = $tax_query;<br \/>\n                $query-&gt;query_vars[&#8216;tax_query&#8217;] = $query-&gt;tax_query-&gt;queries;<br \/>\n            }<br \/>\n        }<br \/>\n        return $query;<br \/>\n    }<\/p>\n","protected":false},"template":"","class_list":["post-9233000","topic","type-topic","status-publish","hentry","topic-tag-detailed","topic-tag-pre_get_posts"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9233000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9233000\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9233000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}