snippets/delete-snippet permanently deletes a snippet. It refuses without confirm: true.
It also does something a plain deletion does not: it verifies the snippet has actually left the loader cache.
Before you run it
This cannot be undone. The code is gone, and if it was the only copy it is not recoverable from anywhere in WordPress. snippets/deactivate-snippet stops the code running while keeping it, and is the right call almost every time somebody says “get rid of this snippet”.
At a glance
| Ability | snippets/delete-snippet |
| Toolset | WPCode — toolset/wpcode |
| Group | WPCode › Snippets |
| Requires | WPCode, active on the site |
| Capability | manage_options |
| Safety | Destructive — deletes stored values, and refuses to run without confirm: true |
| Repeatable | Not idempotent — each call changes the row set, so re-running is not a no-op |
| Ships in | AcrossAI Abilities Manager 0.0.34 and later |
How it works
WPCode does not read the snippets table on every request. It builds a loader cache and runs from that, which is why a snippet can be published in the database and still be completely inert — and why writing the snippet post type directly through the content or database abilities produces a row that looks right and does nothing.
Which produces a genuinely alarming failure mode for deletion: remove the post with WordPress’s own function and the snippet is gone from the admin, gone from the database, and still in the cache — still executing on every request, with no row anywhere to explain where the code is coming from.
So this deletes the snippet, rebuilds the cache, and checks that the snippet is no longer in it before reporting success. A deletion that cannot be confirmed is reported as a failure rather than a success.
Deactivate first if you are diagnosing rather than removing. Deletion is for snippets you are certain about.
Input
| Name | Type | Required | What it is |
|---|---|---|---|
id | integer | Yes | Snippet ID. |
confirm | boolean | Yes — must be true | The irreversibility gate. Without it the call is refused before anything is touched. |
What comes back
| Name | Type | What it is |
|---|---|---|
deleted_id | integer | The ID of the deleted snippet. |
title | string | Its title, for the record. |
success | boolean | Whether the call completed. |
message | string | A one-line summary of what happened, suitable for showing a human. |
error_code | string | Present only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation. |
Example
Ask your assistant:
Delete the old redirect snippet for good.
It resolves to one call:
{
"ability": "snippets/delete-snippet",
"parameters": {
"id": 88,
"confirm": true
}
}Worth knowing
- No trash, no undo. The code is gone.
- Copy the code out first if there is any chance you want it back.
- The cache is rebuilt and verified — a snippet that would keep running is reported, not ignored.
- Prefer deactivation while diagnosing.
Related abilities
- Deactivate Code Snippet — the reversible alternative
- Get Code Snippet — read the code before you lose it
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category