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 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.