Home › Forums › ACF PRO › Query only against post_title in acf/fields/post_object/query › Reply To: Query only against post_title in acf/fields/post_object/query
Yes,
The way I would do this is first add a filter for ACF, in that filter I would add the filter than modifies the query, then after modifying the query I would remove the filter something like this.
add_filter('acf/fields/post_object/query/name=your-field-name', 'modify_my_field_name_query', 10, 3);
function modify_my_field_name_query($args, $field, $post_id) {
//using the example from the original link I posted
add_filter('posts_search', '__search_by_title_only', 500, 2);
return $args
}
function __search_by_title_only($search, $wp_query) {
remove_filter('posts_search', '__search_by_title_only', 500, 2);
/// modify the query as shown in the other post
return $search
}
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.