Clone
4 min read
A Clone field shows the fields of another field group inside the current one. Use it when several groups need the same block of fields (an address, SEO notes, a contact person) and you want to define it once.
Type id |
|
Builder category | Layout |
Column |
|
Returns | an array keyed by sub-field key (like a Group), or |
Prints | nothing on its own: read a sub-field with |
Needs | Pro, Business or Agency plan |
Add a clone
- Create the field group you want to reuse (the source). It stays an ordinary field group with its own location rules and table, and keeps working independently.
- Edit the group that should contain the copy and add a field of type Clone.
- Choose the Source field group.
- Under Fields to clone, tick the fields you want. If you tick none, every field is cloned, including fields you add to the source later.
- Save the group.
Changing the source field group in the select clears the ticked fields, because they belonged to the old group. Until you choose a group the list reads "Choose a source field group to see its fields."
Which fields can be cloned
Only top-level fields of the source that have a column and are plain, free field types: text, text area, number, range, email, URL, password, color, select, radio, checkboxes, button group, true / false, date, date and time, time, link, WYSIWYG, oEmbed, image, file, icon, map and the relational types. These are not copied: Group, Repeater, Gallery, Flexible content, Clone, Programmatic SEO page, Accordion and Tab. A source without cloneable fields shows "This field group has no fields that can be cloned."
A copy takes over the source field's label, type, default value, required flag, instructions, placeholder, settings, validation rules, conditional logic and translation mode. It does not take over Show in the admin list: a clone's sub-fields never get list columns.
Messages when saving
Message | Meaning |
|---|---|
| No source selected. |
| The source is the group that holds the clone. |
| The source is missing, was deleted or has only fields that cannot be cloned, or none of the ticked fields exist. |
You can add several clones of the same source, in one group or in different groups; each is kept apart.
Edit screen
The copied fields appear in the clone's place, in the order of the source, with their own labels, instructions and rules. A required copied field is checked like any other required sub-field. With nothing to clone the screen shows "No fields to clone."
What is saved
The values of all copied fields are saved together as one JSON object keyed by sub-field key, exactly like a Group:
{ "headline": "Hello", "rating": 5 }Each value is cleaned by the field type of its copy. With no value the field is cleared. From code, pass an array:
wpmcf_update_field( 'case_study', 'contact', [ 'headline' => 'Hello', 'rating' => 5 ], $post_id );Writing replaces the whole object.
Reading
$contact = wpmcf_get_field( 'case_study', 'contact' );
// [ 'headline' => 'Hello', 'rating' => 5 ]
$headline = wpmcf_get_field( 'case_study', 'contact', null, [ 'path' => 'headline' ] );A Clone prints nothing by itself, so [wpmcf_field group="case_study" field="contact"] is empty. Print a sub-field with path:
[wpmcf_field group="case_study" field="contact" path="headline"]Page builders read a copied field with a reference such as case_study.contact.headline. See Page builders overview.
How a clone follows its source
Whenever you save the source field group, every field group that clones it is saved again automatically, so its copy of the fields matches the source:
- A field you add to the source appears in clones that clone every field.
- A removed field disappears from the clone.
- A renamed or retyped source field is renamed or retyped in the clone, and stored values follow a rename.
- Required, validation and conditional logic changes follow.
- If two groups clone each other, the update stops instead of looping.
- If the update of one group fails, the error is logged under WPM Fields › Settings › Health and the other groups are still updated.
- On a very large table the change is queued in the background, like any schema change.
A clone that lists specific fields keeps them by field key. If you rename one of those fields in the source, the clone no longer finds it and drops it from the copy (the stored value stays in the database but no longer shows or saves). Open the clone and tick the renamed field again. A clone that clones every field has no such problem.
If you delete the source group, the clone keeps its last copy of the fields and keeps working.
Where it works
- Not inside a Group or Repeater, and no list columns for the copied fields.
- The copied fields are not Programmatic SEO data source columns (the clone is one JSON column).
- Builder pickers list the Clone field as one field; address copied values with a path.
Without a license
Values keep printing, and the copy keeps following its source group. The edit screen shows the field locked and keeps the value. See License expiry.
Troubleshooting
- A cloned field is missing. Its type cannot be cloned (Group, Repeater and the Pro types are skipped), or you ticked specific fields and the field was renamed in the source.
- The shortcode prints nothing. A Clone prints nothing; use
path.
Still stuck? Contact support