Hi,
I am trying to extend searching capabilities in acf Post Object field, where one can chose podcasts . He needs to be able to search these podcasts with extra title created with acf text field.
Just to mention that this post object is in flexible content repeater.
Here is my code that should work but it doesn’t, any idea ?
add_filter('acf/fields/relationship/query/name=podcasts_obj', 'my_custom_relationship_query', 10, 3);
function my_custom_relationship_query($args, $field, $post_id) {
// Limit the filed i want to extend
if ($field['name'] == 'podcasts_obj') {
// Searched extra title
$podcast_sub_title_field_name = 'podcast_sub_title';
// Default settings
$search_term = isset($_POST['search_term']) ? $_POST['search_term'] : '';
// Add meta_query with podcast_sub_title field
$args['meta_query'][] = array(
'key' => $podcast_sub_title_field_name,
'value' => $search_term,
'compare' => 'LIKE',
);
}
return $args;
}