Home › Forums › ACF PRO › Problem with search title in PostObject › Reply To: Problem with search title in PostObject
EDIT:
Code I posted is bad, this is my code:
function custom_acf_post_object_query( $args, $field, $post_id ) {
// Get the search text
$the_search = $args['s'];
// Remove it so ACF won't search the posts based on title
unset($args['s']);
// Search based on custom fields only
$meta_query_args = array(
'relation' => 'AND',
array(
'relation' => 'OR',
array(
'key' => 'post_title',
'value' => $the_search,
'compare' => 'LIKE'
),
array(
'key' => 'content_shop_api_key',
'value' => $the_search,
'compare' => 'LIKE'
)
),
array(
'key' => 'free_content_check',
'compare' => 'LIKE',
'value' => $the_search,
)
);
$args['meta_query'] = $meta_query_args;
return $args;
}
add_filter('acf/fields/post_object/query/name=assign_user_product', 'custom_acf_post_object_query', 10, 3);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.