Forums › Forums › Search & Filter Pro › Relation OR in filter
Tagged: filter, meta_query, relation OR
- This topic has 3 replies, 2 voices, and was last updated 4 years, 7 months ago by Trevor.
-
Anonymous(Private) April 30, 2020 at 5:43 pm #242232
Hi there,
we would like to add a reltion OR about two field.
We can’t set it in admin panel so we try to integrate it by php.
In function.php we add this:function filter_results( $query_args, $sfid ) { if($sfid==3981) { $query_args = array( "meta_query" => array( 'relation' => 'OR', array( 'key' => 'immobile_disponibile', 'compare' => 'NOT EXISTS', ), array( 'key' => 'immobile_disponibile', 'value' => '1', 'compare' => 'NOT LIKE', ), ), "meta_key" => "immobile_disponibile", 'orderby' => 'menu_order', "order" => "ASC", ); } return $query_args; } add_filter( 'sf_edit_query_args', 'filter_results', 20, 2 );
But… not work.
Anonymous(Private) May 1, 2020 at 11:42 am #242302I use “OR relation” in WP loop on https://www.houseandtrade.com/
For example I use on this page https://www.houseandtrade.com/agenzia-immobiliare-lugano-ticino/case-ville/I would like to add the “OR relation” in the filter…
There is a custom field (immobile_disponibile) with three value: 0, 1 and null.
In WP loop, I show only post with value 0 or null.I need the same result in the filter…
In this moment, the filter working without “OR relation” because, if add it, the filter not show any result.Trevor(Private) May 1, 2020 at 11:50 am #242306I think you would need to code this into our query using this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
It takes the same structure of arguments as wp_query().
-
AuthorPosts