Support

Account

Home Forums ACF PRO Get value of another field in same group as current field Reply To: Get value of another field in same group as current field

  • Hi @db9429

    Please keep in mind that how you get the cloned value depends on your clone field settings. If you have the standard settings (Prefix Field Names set to “No”), then you can just get the highlight_color field as usual. Don’t forget to pass the current post ID like this:

    add_filter( 'acf/format_value/type=text', 'add_highlight_html' );
    function add_highlight_html( $value, $post_id, $field )
    {
        $color_of_other_field = get_field('highlight_color', $post_id);
        
        $value = str_replace( '[highlight]', '<span class="highlight" style="color: '. $color_of_other_field .'">', $value );
        $value = str_replace( '[/highlight]', '</span>', $value );
    
        return $value;
    
    }

    This page should give you more idea about it: https://www.advancedcustomfields.com/resources/clone/.

    I hope this helps 🙂