bricks_delete_custom_element
Overview
Deletes a custom Bricks element by removing its PHP file from the child theme. After deletion, the element type will no longer be available in the Bricks element panel, and any existing instances on pages will stop rendering.
This is a destructive operation. Unlike components which have a usage check, custom element deletion does not verify whether instances exist on pages. Ensure no pages are using the element before deleting it.
Key Features
When to Use
When cleaning up test or draft elements during development
When replacing an element with a newer version (create new first, then delete old)
Verify no pages are using the element (use bricks_search_content to check)
A Bricks child theme must be active
When NOT to Use
When you want to update the element — use bricks_update_custom_element instead
When you want to temporarily disable it — there is no disable option, consider renaming instead
Parameters
Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
namestringREQUIREDCode Examples
Delete a custom element
Removes the pricing-card custom element from the child theme.
bricks_delete_custom_element({
name: "pricing-card"
}){
"success": true,
"message": "Custom element 'pricing-card' deleted successfully"
}Common Mistakes
// Deleting without checking usage
bricks_delete_custom_element({ name: "pricing-card" })// Step 1: Search for usage
bricks_search_content({ query: "pricing-card" })
// Step 2: Remove instances from pages
// Step 3: Then delete safely
bricks_delete_custom_element({ name: "pricing-card" })Tips & Warnings
Destructive and immediate: The PHP file is deleted from disk immediately. There is no undo or trash mechanism. Back up the file contents using bricks_read_custom_element before deleting.
No usage check: Unlike bricks_delete_component, this tool does not check for existing instances. Manually verify no pages use the element before deleting.
Broken instances: Pages with instances of the deleted element will show empty or broken elements. Clean up instances before deleting the element definition.