Hello,
I am trying to add custom fields created by ACF to my search, I am using meta_query, but my searches do not get any results from data in the ACF’s
$this_key = $_GET['keyword'];
$args = array (
'post_type' =>'resources',
'post_status' => 'publish',
'posts_per_page' => 100,
'order' => 'ASC',
's' => $this_key,
'meta_query' =>
array(
'relation' => 'OR',
array(
'key' => 'agency',
'value' => $this_key ,
'compare' => 'LIKE'
),
array(
'key' => 'available_form',
'value' => $this_key,
'compare' => 'LIKE'
)
)
);
If someone is looking for a solution to this problem is to recommend the plugin:
https://wordpress.org/plugins/acf-better-search/
This plugin adds to default WordPress search engine the ability to search by content from selected fields of Advanced Custom Fields plugin.
Everything works automatically, no need to add any additional code.