Support

Account

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
    }