Support

Account

Home Forums ACF PRO Search custom fields not just post title in Relationship Post Object Field Reply To: Search custom fields not just post title in Relationship Post Object Field

  • When searching in a relationship or post object field ACF uses the standard WP search which searches the title and content.

    In order to allow the search to look at custom fields you would need to create an acf/fields/relationship/query filter in combination with other WP filters https://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/

    I don’t really have the details on how to do this because you have to find a way to only modify the search when ACF is searching for the field

    Another explanation https://www.jclabs.co.uk/customize-wordpress-search-results/ Looking at this example you would add the filter hooks inside of your acf/fields/relationship/query filter. These would need to be applied to only the current query which means you’d also need to remove these filters when the query is done. There is a hook that runs after the query in WP and that is “the_posts“, you could potentially add this filter as well and remove all the other filters when this filter is run.