Home › Forums › Backend Issues (wp-admin) › Relationship field not searching custom fields › Reply To: Relationship field not searching custom fields
The search in the relationship fields uses the standard WP ‘s’ parameter for WP_Query http://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter. If you want to extend the query to also search custom fields then you’ll need to modify the query.
I would start here https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/
And I’d take a look at at the parse_search()
function in /wp-includes/query.php. It’s on line 2112 in the current version of WP.
I’m not sure you can do this by just adding a complicated meta query. You may need to hook into where the query is done and alter it there, you may even need to build a completely custom query and to the db query yourself.
There are some plugins available that will alter searches, one of them is https://wordpress.org/plugins/search-everything/, but I’ve seen this plugin cause a site with a lot of posts and custom fields to time out.
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.