Support

Account

Home Forums Add-ons Flexible Content Field Clone partial used in multiple contexts Reply To: Clone partial used in multiple contexts

  • If you clone a field group you should never need to update the field groups that they are cloned into. The clone pulls in the fields in the cloned group, it does not copy the cloned group.

    How I get around the get)field() or get_sub_field() issue is that I don’t. When I clone a group of fields the clone is in a group field. This means that they are always sub fields and that the field names till not conflict. Here’s an example. I have a component field group for CTAs. I use it everywhere to allow clients to add CTA buttons to damn near anything. My flex layouts all have an optional header and footer. In the header section there is a field names “header_ctas” that is a group field and the only sub field is the clone of my cta component group. Every layout also has an optional footer and in this section there is a group field named “footer_cta”. Then in my template file for either the header of the footer, or anywhere else I simply do

    
    if (have_rows('group_field_name')) {
      while (have_rows('group_field_name')) {
        the_row();
        get_template_part('template-parts/components/ctas');
      }
    }