Home › Forums › ACF PRO › Customizing the Post Relationship search field… › Reply To: Customizing the Post Relationship search field…
When performing the search ACF uses the standard WP search feature.
You would need to add a filter https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/
In this filter you would add a second filter following this https://stackoverflow.com/questions/9468804/make-wordpress-search-only-in-post-title
add_filter('acf/fields/relationship/query/name={YOUR FIELD NAME}', 'my_acf_fields_relationship_query', 10, 3);
function my_acf_fields_relationship_query( $args, $field, $post_id ) {
add_filter('posts_search', '__search_by_title_only', 500, 2);
return $args;
}
function __search_by_title_only($search, &$wp_query) {
// code from stack
}
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.