Support

Account

Home Forums General Issues Add custom field to searchable results in relationship field

Unread

Add custom field to searchable results in relationship field

  • Hi,

    I’ve managed to get a product code to appear in the relationship field, but I would like that code to be searchable too from the relationship search bar… is that possible?

    thanks,

    function my_acf_relationship_result( $html,  $object, $field, $post )
    {
        // add an image to each result
       
            $code = get_field('product_code') ;
      
            $html = '<span style="font-size: 0.75em; color: #999" >' . $code . ' - </span>' . $html;
    
       return $html;
    }
     
    // acf/fields/relationship/result - filter for every field
    add_filter('acf/fields/relationship/result', 'my_acf_relationship_result', 10, 4);
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.