30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Get Code Snippet

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

Abilitysnippets/get-snippet
ToolsetWPCode — toolset/wpcode
GroupWPCode › Snippets
RequiresWPCode, active on the site
Capabilitymanage_options
SafetyRead-only — changes nothing
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI 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

NameTypeRequiredWhat it is
idintegerYesSnippet ID.

What comes back

NameTypeWhat it is
snippetobjectID, title, code, code type, active state, location, auto-insert flag, priority, tags, note, custom shortcode, conditional logic and the last recorded error.
in_cachebooleanWhether WPCode’s loader cache holds the snippet. This, not the post status, is what decides whether it actually runs.
safe_modebooleanWhether safe mode is active. When it is, no snippet runs regardless of everything else.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent 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


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading