Support

Account

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

Unread

Search custom fields not just post title in Relationship Post Object Field

  • How would I based on the following filter of a Relationship Post Object in ACF Pro be able to enable search on the post object field and add the ability to search by more than just the post title? I’d like to allow searching by Sq ft, Price, Community, etc. beyond just the standard post title. Let me know.

    add_filter('acf/fields/relationship/result/name=show_as_community_model', 'my_acf_fields_relationship_result', 10, 5);
    function my_acf_fields_relationship_result( $text, $post, $field, $post_id ) {
      $community = get_field ('community', $post->ID);
      $sqft = get_field('sq_ft', $post->ID);
      $mls = get_field('mls', $post->ID);
      $price = get_field('price',$post->ID);
    	
        if ($post->post_type == 'home_listings') {
            $text .= ' •  Community:  ' . $community->post_title . ' •  Lot:  ' . $lot . '  •  SqFt:  ' . $sqft . ' •  MLS: ' . $mls . ' •  Price:  ' . $price . '';
        }
        return $text;
    }
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.