Well actually I tried it also and still the same result…
This is how I tried to hook the query filter:
function modify_acf_relationship_search_query ($args, $field, $post ) {
$args['meta_query'] = array(
'key'=> '_sku',
'value'=> '$args['s'],
'compare' => 'LIKE'
);
return $args;
}
add_filter('acf/fields/relationship/query/name=related_products', 'modify_acf_relationship_search_query', 10, 3);
Again, this hook doesn’t work, The query always showing no results.
Ok, so I need to buy ACF5 just for adding a simple query ?
I’m using ACF version 4.4.11 , but my wordpress version is quite old – 4.4.5.
Hello,
I’m having the same issue. I’m using Woocommerce, so I need the relationship field to be able to filter by product’s sku. I used the hookes mentioned above by @pedrolima, the original hooks are from StackExchange: http://wordpress.stackexchange.com/questions/178574/acf-relationship-field-search-filtering/207853
Those hooks are working great (they can search in meta data as well as post title) but, as @pedrolima said, it causes to loop the first result again and again instead of showing the relevant results.
Before I used those hooks from Stackoverflow, I tried to use the filter @hube2 mentioned “acf-fields-relationship-query”, I added the meta query that I need to $args array but unfortunately it didn’t work as excepted… It showed no results for any search I typed.
Any help will be appreciated!