Support

Account

Home Forums General Issues How to output a cloned Group field, with the clone display of Group

Solved

How to output a cloned Group field, with the clone display of Group

  • Hi,

    This may get a little confusing because of all the things that use the term ‘Group’ but i will try and be as clear as possible

    TLDR: How do you output a cloned ‘Group field’ while using the clone display setting of ‘Group’?

    More detailed description of my setup:
    I essentially have a field group that contains all of my necessary fields, however they will need to be displayed multiple times per flexible layout, my solution to this was to clone them into multiple other field groups each within a Group field.

    I then clone the newly created field groups into my flexible content layout, meaning I can essentially have the same fields cloned next to each while also only having to update the original Field Group.

    This all works perfectly when displaying them seamlessly inside the flexible content, however when using the ‘Group’ display on the clone fields (I need to display them conditionally, which you cant do when displayed seamless) inside of the flexible content, I cannot figure out how to get them to output anything.

    Im not sure I explained that very well so I have included a diagram: the highlight red is where im tripping up
    Fields Setup and Flow

    I realise this is a pretty specific issue but hopefully someone has an aswer or has done this before.. If you want me to upload any code or anything else just let me know

  • Figured out a solution that works! Was actually much simpler than I was thinking it was, Here is an example:

    <?php 
    
    $clone_var = get_sub_field( 'clone_field_name' );
    
    $group_var = $clone_var['group_field_name'];
    
    if( $group_var ) :
    
        $field_var = $group_var['field_name'];
    
        echo $field_var;
    
    endif;
    
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘How to output a cloned Group field, with the clone display of Group’ is closed to new replies.