bricks_delete_section
Overview
Delete a section and all its child elements from a Bricks page. Identifies the section by its root element ID and recursively removes all descendants. The remaining sections on the page are unaffected and maintain their positions.
Use bricks_get_page_content first to find the section ID you want to remove. This is a destructive operation — the section content cannot be recovered through the API (though WordPress revisions may still have it).
Key Features
When to Use
You are cleaning up duplicate or test sections
A section needs to be removed as part of a page redesign
You want to reduce the page to fewer sections
When NOT to Use
You only need to remove a single element within a section (use bricks_delete_element instead)
You want to reorder sections without removing any (use bricks_reorder_sections instead)
Parameters
page_idnumberREQUIREDsection_idstringREQUIREDCode Examples
Delete a section from a page
Find the section ID, then remove it along with all its child elements.
// Step 1: Find section IDs
bricks_get_page_content({ page_id: 42, mode: "summary" })
// Find the section to remove: id "a1b2c3"
// Step 2: Delete the section
bricks_delete_section({
page_id: 42,
section_id: "a1b2c3"
}){
"success": true,
"message": "Section a1b2c3 deleted from page 42",
"elements_removed": 12
}Common Mistakes
bricks_delete_section({ page_id: 42, section_id: "a1b2c3" })
bricks_update_element({ page_id: 42, element_id: "d4e5f6", ... })
// d4e5f6 was inside the deleted section!bricks_delete_section({ page_id: 42, section_id: "a1b2c3" })
// Now add a new section if needed
bricks_add_section({ page_id: 42, section: { ... } })Tips & Warnings
Irreversible via API: There is no undo. WordPress may have the previous version in its revision history, which you can restore with bricks_restore_revision.
Use replace instead of delete + add: If you want to swap a section for a new one, use bricks_replace_section instead of deleting and then adding — it is more efficient and maintains position.