The relationship field uses a WP_Query to find the posts. In the args, the search parameter is set as
s. You can read about this here: http://codex.wordpress.org/Class_Reference/WP_Query
It is possible then to find a plugin or write some custom code that extends the WP search functionality to search also the post_content.
I think the default WP_Query behaviour is to search both post_title and post_content, so I am surprised this is not working in the Relationship field.
Assuming this was a choice made by you, is there any suitable hook in ACF to override this? (Such as a filter in Relationship field.)
Or do you think there is a WP core hook?
I have WP Custom Fields Search plugin installed – it is an exellent solution to search content from the front-end not only in Post Title or Post content, but all other custom fields.
Unfortunately in back-end AJAX search for Relationship field is searching only Post Title, not even Post Content, as SnitchHomer said.
Is it possible to do some customization to make search possible not only by Title, but by Body and all (or some) text custom fields?
For example we have such structure:
1. Movie post type
2. Actor post type
In Movie custom fields I have Actors realtionship field, that helps me to choose actors, that cast in the movie.
Each Actor have additional Custom Fields, like Original name, Nickname and other Text Fileds, that helps me to quckly search actors database.
It will be great if I can search Actors not only by their Name, but also any of Custom Fields.
I would be grateful for any help.
As I have written above, ACF uses a WP_Query with a
s argument to search. WP should natively search post_content in a new WP versions, but you can always hook in and modify the WP_Query args like so:
I can’t explain why, but my first thought is that you have a plugin, or theme code which is modifying the way that WP searches data.
Perhaps, the issue is due to an older version of WP? I’m not sure which version the better search was added, but it is one of the most recent versions.
The topic ‘Extending Search functionality in Relationship field to include post body’ is closed to new replies.
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!
Sorry for the issues with ACF's API SSL certificate this morning. We've resolved it and your activations and downloads should be back to normal again. Thanks! ^LG— Advanced Custom Fields (@wp_acf) November 2, 2022
© 2022 Advanced Custom Fields.