WPLake > Learning Hub > ACF Clone Field

ACF Clone Field

Enhance content management with ACF Clone field: Streamline field linking, ensure seamless integration, and boost efficiency in diverse field types.

Key Points at a Glance

  1. About the Clone field: Within the Advanced Custom Fields (ACF) plugin, the Clone field stands out for its ability to link fields or entire groups, avoiding duplication and simplifying content management.
  2. Links fields instead of copying: Unlike manual copying, the Clone field establishes links between selected fields or groups, enabling centralized modifications across all instances.
  3. Maintains original field names: Cloned fields retain their original names, facilitating code interaction, with an option to apply name prefixes to prevent conflicts.
  4. Seamless display: Cloned fields integrate seamlessly into layouts by default but offer options for differentiation when necessary, enhancing design flexibility.
  5. Can be used inside Repeater, Group, and Flexible: The Clone field can link fields within other field types like Repeater, Group, or Flexible, offering flexibility and efficiency in field creation and management.

Table of Contents

Intro

Advanced Custom Fields (ACF) stands out as one of the most widely used meta-field plugins. Within ACF, the Clone field type emerges as a distinct and versatile feature.

Unlike traditional field types, the Clone field is unique in that it doesn't possess its inputs or values. Instead, it serves as a virtual connector, facilitating the linking of other fields or entire groups within various contexts, including nested groups or layout field types, such as group or repeater.

ACF clone field settings
The Clone field allows you to 'link' fields or even an entire group inside another group or a layout field

Let's explore the five key facts about the Clone field that unveil its potential and versatility:

1. Allows to avoid duplicates

While ACF Group allows us to set up multiple location rules for the whole group, what about reusing the same set of fields in several groups? Or reuse fields inside other fields, like repeater? The ACF Clone Field allows us to avoid duplicates and solve these tasks efficiently.

Reusing content is key to efficient systems, as duplicated content not only clutters the database but also complicates maintenance and updates. To avoid duplication in code, you should structure it modularly or use plugins that implement this approach, such as Advanced Views.

So, with the Clone Field, you can effortlessly replicate one or more fields or even a whole group without making independent copies manually. This not only saves time but also ensures consistency across your website.

2. Links fields instead of copying

The primary advantage of utilizing the Clone field instead of manual copying lies in its ability to link selected fields or a group, rather than simply duplicating them. Consequently, any modifications can be made in a single location.

Additionally, when an entire group is cloned, the ability to add or remove fields in one location ensures that these changes are applied across all linked instances.

3. Maintains the original field names

Another crucial aspect to understand about the Clone field is how it handles the fields it clones. It maintains the original field names of the cloned items, allowing you to interact with the "cloned" fields in code using the ACF get_field function or inside the smart templates just like ordinary fields.

Moreover, for the cloned fields there's an option to apply a 'name prefix', particularly useful if you want to prevent name conflicts. For instance, suppose we have a 'Company' group and wish to clone the 'Contact details' group.

By default, field names remain identical, potentially leading to conflicts such as having another 'phone_number' field within the same group. To mitigate this, you can set up a field prefix within the clone field settings. Consequently, cloned fields will be stored in the database with the prefix, such as 'clone_prefix_phone_number'.

Tip: It's important to note that while the prefix setting offers a solution to potential naming conflicts, it's best used sparingly due to its impact on modularity. It's advisable to provide clear names by default.

Using the prefix may result in code that's unable to reuse existing functionality for displaying fields from the cloned group, as the names will have changed.

4. Display the cloned fields seamlessly (by default)

Now let's examine how the cloned fields appear for editors. By default, the clone displays them seamlessly, meaning they appear like any other fields added to the group.

Seamless display option of the Clone field
The seamless display option draws the cloned fields just like any others inside the field group

However, there might be occasions when you need to distinguish them. For instance, in the scenario where the 'location' group is cloned into the 'Company' group, you can modify the display setting from 'seamless' to 'group'.

Group look of the Clone field for editors
Cloned fields with the 'Group' display option

This adjustment will present the cloned fields within a distinct group, resembling the layout when using the ACF Group field.

5. Can be used inside Repeater, Group, and Flexible

As previously mentioned, you can "link" fields using the Clone field not only within another group but also within other fields, such as layout group fields like Group, Repeater, or Flexible.

This functionality proves to be incredibly useful and has just as many use cases as linking one group inside another. Let's consider an example:

Suppose you have a Testimonials ACF Gutenberg block, with a ready template and styles.
Now you're creating a Flexible Content field, called "Content Sections" where you can add various layouts, like about us, contact us, and others.

Within one of these content blocks, if you need to display testimonials, instead of creating these fields from scratch, you can utilize the "clone" field to link to our existing set of testimonial fields. Since we already have the templates and styles for our testimonials, we can simply reuse them.

This not only saves a significant amount of time but also ensures consistency and efficiency across your content sections. To maximize the benefits of the modular approach, consider utilizing smart templates from the Advanced Views framework, which offers a modular and hassle-free solution right out of the box.

Summary

The Clone field, a unique feature within the ACF plugin, acts as a virtual connector, seamlessly linking other fields or entire groups. It enables efficient reuse of fields or groups across multiple instances, streamlining database management and simplifying maintenance tasks.

Unlike manual copying, the Clone field establishes links between selected fields or groups, ensuring that modifications can be centrally managed while maintaining consistency across instances. Furthermore, cloned fields retain their original names, facilitating code interaction.

They seamlessly integrate into the layout by default, blending with other fields in the group, yet offering options for differentiation when necessary, thus enhancing design flexibility.

Moreover, the Clone field seamlessly integrates with various field types like Repeater, Group, or Flexible, providing flexibility and efficiency in field creation and management.

Was this article helpful?

Totally useless

Slightly helpful

Very helpful

FAQ mode

/

Learning mode

  1. What is the primary advantage of using the Clone field over manual copying?

    The Clone field links selected fields or groups instead of duplicating them, allowing for centralized modifications across all linked instances, ensuring consistency in content updates.

  2. How does the Clone field handle the names of cloned fields?

    Cloned fields retain their original names by default, facilitating code interaction, with an option to apply name prefixes to prevent naming conflicts.

  3. In what contexts can the Clone field be used within the ACF plugin?

    The Clone field can be used within various field types like Repeater, Group, or Flexible, allowing for efficient linking of fields across different contexts, streamlining field creation and management.

Related articles

Content links (13)

About the Author

Maxim Akimov

Certified WordPress expert from Ukraine with over 8 years of experience. Advocate of the BEM methodology and the overall modular approach. Loves sporting activities and enjoys going to the gym and regularly plays table tennis.

0 Comments

    Leave a comment

    Reply to 

    Please be considerate when leaving a comment.

    Not shown publicly

    Got it