bricks_delete_page

Phase 4BeginnerDestructiveComplexity: 2/10
Delete a page (trash or permanent)

Overview

Delete a WordPress page. By default the page is moved to the trash (recoverable), but you can permanently delete it by setting force to true. Always use bricks_list_pages first to verify the correct page ID before deleting.

After deletion, any links pointing to this page across the site become broken. Run bricks_scan_links with the « broken » filter to find and fix stale references in menus, headers, footers, and other pages.

Key Features

Soft Delete (Trash)
By default moves the page to trash, making it recoverable from the WordPress admin.
Permanent Delete
Set force to true to permanently remove the page and all its Bricks element data. This cannot be undone.
Confirmation Response
Returns the deleted page title and final status so you can verify the correct page was removed.

When to Use

You need to remove an old or duplicate page from the site
You are cleaning up draft or test pages that are no longer needed
A page has been replaced and the old version should be removed
You need to permanently delete a page from the trash
Prerequisites
Run bricks_list_pages to confirm the correct page ID. Check if the page is referenced in navigation menus or other pages. After deletion, run bricks_scan_links to find and fix broken links.

When NOT to Use

You want to hide a page temporarily (change its status to draft or private instead)
You are unsure which page to delete (use bricks_list_pages to verify first)
The page is the homepage (use bricks_set_homepage to reassign first)

Parameters

2 Total Parameters1 Required1 Optional
page_idnumberREQUIRED
The WordPress page ID to delete. Use bricks_list_pages to find the correct ID.
forcebooleanoptional
If true, permanently deletes the page instead of moving to trash. Cannot be undone.
Default: false Values: true, false

Code Examples

Move a page to trash

Soft-delete a page so it can be recovered later if needed.

JSON
bricks_delete_page({
  page_id: 55
})
Response
{
  "success": true,
  "message": "Page 55 moved to trash.",
  "page": {
    "id": 55,
    "title": "Old About Page",
    "status": "trash"
  }
}

Permanently delete a page

Force-delete a test page that is no longer needed.

JSON
// Step 1: Verify the page
bricks_list_pages({ search: "Test Page" })

// Step 2: Permanently delete
bricks_delete_page({
  page_id: 99,
  force: true
})

// Step 3: Fix any broken links
bricks_scan_links({ filter: "broken" })
Response
{
  "success": true,
  "message": "Page 99 permanently deleted.",
  "page": { "id": 99, "title": "Test Page", "status": "deleted" }
}

Common Mistakes

Deleting a page without checking for references
After deletion, run bricks_scan_links to find and fix any broken links in menus, headers, footers, and other pages that pointed to the deleted page.
Wrong
bricks_delete_page({ page_id: 55 })
// Broken links remain in menus and footer!
Correct
bricks_delete_page({ page_id: 55 })
bricks_scan_links({ filter: "broken" })
bricks_update_links({ updates: [...] })
Using force delete when soft delete is sufficient
Use the default soft delete (trash) unless you are certain the page is no longer needed. Trashed pages can be recovered from wp-admin.
Wrong
bricks_delete_page({ page_id: 55, force: true })
// Cannot be undone!
Correct
bricks_delete_page({ page_id: 55 })
// Recoverable from trash

Tips & Warnings

Tips & Warnings

Always verify first: Use bricks_list_pages to confirm the correct page ID before deleting. Deleting the wrong page can cause significant data loss.

Fix broken links: After deleting a page, run bricks_scan_links({ filter: « broken » }) to find and repair any references to the deleted page across the site (Phase 4.7).

Homepage safety: If the page is the current homepage, reassign the homepage to another page with bricks_set_homepage before deleting.

Return Values

FieldTypeDescription
successbooleanWhether the deletion was successful.
messagestringConfirmation message indicating trash or permanent deletion.
page.idnumberThe ID of the deleted page.
page.titlestringThe title of the deleted page.
page.statusstringThe final status of the page (trash or deleted).

Related Tools

Technical Details

Tool ID
bricks_delete_page
API Endpoint
/wp/v2/pages/{page_id}
HTTP Method
DELETE
Namespace
pages-elements
Source File
wordpress/site-info.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release with soft delete (trash) and permanent delete options.
20250101