Conflict with WP Ultimate Recipe search widget
-
I’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.
I looked into the code for the WPUR widget, and it basically uses the ‘pre_get_posts’ 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.
I joined the callback’s code below.
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’s a “custom” search query, and in this case don’t activate itself ?
Or would there be a better solution on WPUR plugin side ?
Regards,
Pascal.
public function pre_get_posts_search( $query )
{
if( $query->is_search && isset( $_GET[‘wpurp-search’] ) )
{
// Only search for recipes
$query->set( ‘post_type’, ‘recipe’ );// Check taxonomy filters
$tax_query = array();
foreach( $_GET as $tag => $term )
{
if( substr( $tag, 0, 7 ) == ‘recipe-‘ && $term != ‘0’) {
$tax_query[] = array(
‘taxonomy’ => substr( $tag, 7 ),
‘field’ => ‘id’,
‘terms’ => array( intval( $term ) ),
);
}
}
if( !empty( $tax_query ) ) {
$query->tax_query->queries = $tax_query;
$query->query_vars[‘tax_query’] = $query->tax_query->queries;
}
}
return $query;
}
- The topic ‘Conflict with WP Ultimate Recipe search widget’ is closed to new replies.