bricks_duplicate_element
Overview
Duplicate an existing element (and all its children) on a Bricks page. The copy is inserted immediately after the original element within the same parent container. All child elements are recursively duplicated with new unique IDs.
This is useful for quickly creating variations of existing elements — for example, duplicating a card in a grid and then updating its content with bricks_update_element, rather than building a new card from scratch.
Key Features
When to Use
You need another instance of a complex element structure that you will then customize
You are building a grid and want to duplicate the first card to create additional cards
You need a second CTA or content block with a similar layout to an existing one
When NOT to Use
You need the copy in a different parent container (use bricks_insert_element or bricks_move_element instead)
You want to copy a section to a different page (use bricks_copy_section instead)
You want an exact sync copy that updates globally (use bricks_create_global_element instead)
Parameters
page_idnumberREQUIREDelement_idstringREQUIREDcontent_areastringoptionalcontent Values: content, header, footerCode Examples
Duplicate a card and customize it
Duplicate an existing feature card in a grid, then update the text on the copy.
// Step 1: Duplicate the first card
bricks_duplicate_element({
page_id: 42,
element_id: "card01"
})
// Returns new card with id "card01_dup"
// Step 2: Customize the duplicate
bricks_update_element({
page_id: 42,
element_id: "new_heading_id",
settings: { text: "Different Feature Title" }
}){
"success": true,
"new_element_id": "q7r8s9",
"elements_created": 4,
"id_map": {
"card01": "q7r8s9",
"icon01": "t1u2v3",
"heading01": "w4x5y6",
"text01": "z7a8b9"
}
}Common Mistakes
bricks_duplicate_element({ element_id: "card01" })
bricks_duplicate_element({ element_id: "card01" })
bricks_duplicate_element({ element_id: "card01" })
// 3 duplicates = should be a component!bricks_create_component({
label: "Feature Card",
elements: { ... },
properties: [...]
})
// Use componentId + properties for each instanceTips & Warnings
Use components for repeated patterns: If you find yourself duplicating the same element 3+ times, stop and create a component instead. Components are maintainable and update globally.
Update after duplicating: The duplicate has identical content to the original. Always follow up with bricks_update_element to customize the text, images, or other content of the copy.
New IDs: The id_map in the response tells you which new IDs correspond to which original elements, making it easy to target specific children for updates.