I am using wordpress 4.9.7 and I am using advanced custom fields 4.4.12.
In my backend I have a post type that is called coins, which has a relationship field called related_coins and a text-field, which is called algorithm. Basically my relationship field creates a relationship to the custom post type products. So product can have a relationship with several coins.
I currently only can filter by post type. However, I would like to filter by the custom field algorithm of the post type coin.
I tried the following:
function graphic_card_products_query( $args, $field, $post_id ) {
$args['meta_query'] = array(
array(
'key' => 'algorithm', // name of custom field
'value' => 'related_coins',
'compare' => 'LIKE'
)
)
// return
return $args;
}
// filter for every field
add_filter('acf/fields/relationship/query/name=related_coins', 'graphic_card_products_query', 10, 3);
Basically I am trying to get a list of all values that the custom field algorithm has and hand it as a filter option back to the relationship field related_coin.
Currently I do not get anything back.
Any suggestions what I am doing wrong?
from Add filter to acf relationship field

No comments:
Post a Comment