snippets/get-snippet reads one snippet completely: its code, its type, whether it is active, where it is inserted, its priority, its tags, its conditional logic, and the last error WPCode recorded for it.
It also reports whether the loader cache holds it.
At a glance
| Ability | snippets/get-snippet |
| Toolset | WPCode — toolset/wpcode |
| Group | WPCode › Snippets |
| Requires | WPCode, active on the site |
| Capability | manage_options |
| Safety | Read-only — changes nothing |
| Repeatable | Idempotent — running it twice leaves the same result |
| Ships in | AcrossAI Abilities Manager 0.0.34 and later |
How it works
The recorded error is the part people do not know to look for. WPCode catches a fatal in a PHP snippet, switches the snippet off, and stores the message against it. Nothing sends a notification; the snippet simply stops working and the reason sits on the record.
Reading the error and the active state together usually explains the whole situation: inactive with an error means WPCode turned it off, inactive without one means a person did.
Conditional logic comes back in full. A snippet that is active, cached and still not appearing is very often a snippet whose rules never match.
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.
Input
| Name | Type | Required | What it is |
|---|---|---|---|
id | integer | Yes | Snippet ID. |
What comes back
| Name | Type | What it is |
|---|---|---|
snippet | object | ID, title, code, code type, active state, location, auto-insert flag, priority, tags, note, custom shortcode, conditional logic and the last recorded error. |
in_cache | boolean | Whether WPCode’s loader cache holds the snippet. This, not the post status, is what decides whether it actually runs. |
safe_mode | boolean | Whether safe mode is active. When it is, no snippet runs regardless of everything else. |
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:
Why has snippet 88 stopped working?
It resolves to one call:
{
"ability": "snippets/get-snippet",
"parameters": {
"id": 88
}
}Worth knowing
- Inactive with a recorded error means WPCode switched it off after a fatal.
- Active, cached and invisible usually means conditional logic.
- The note field is internal and never rendered on the site.
Related abilities
- Update Code Snippet — fix the code
- Clear Snippet Errors — clear the record after fixing
- Set Snippet Conditional Logic — why it may not be showing
Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager
Browse the rest: Every ability, by category