Add Code Snippet is a WordPress ability from The Plus Addons for Elementor — usable via Easy MCP AI, which connects Claude, ChatGPT, and any AI assistant to your site.
Install Free Plugin →Add Code Snippet
WriteCreates a site-wide Custom Code snippet using Elementor Pro, injecting CSS/JS/meta into the head or body on all pages.
Requires the The Plus Addons for Elementor plugin (which registers under the 'tpae' ability category) on WordPress 6.9+, with Elementor active. Every ability requires the current user to have the 'edit_posts' capability (and 'edit_post' for the specific post being modified); abilities that create or edit content also verify Elementor and, where relevant, the target The Plus widget are available. A subset of abilities (theme templates, template conditions, dynamic tags, popups, and some custom-code abilities) only register when Elementor Pro is active, and many widget abilities load only in the free plugin when the Pro add-on is inactive.
What it does
Maps the user-facing location (head/body_start/body_end) to Elementor's internal location keys, clamps priority to 1-10, validates status is publish or draft, then creates a new elementor_snippet CPT post with the given title/status. Sets _elementor_location, _elementor_priority, _elementor_code, _elementor_template_type ('code_snippet'), and _elementor_edit_mode post meta, plus an ensure_jquery extra option if requested. Returns the snippet ID, title, location, priority, status, and admin edit URL.
See it in action
You ask your AI assistant
"Add a site-wide Google Analytics tracking snippet to the page head with priority 1."
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Descriptive title for the snippet (e.g. "Google Analytics", "Global CSS overrides"). |
| code | string | Yes | The full code to inject. Include <script>, <style>, or <meta> tags as needed. |
| location | string | No | Where to inject: "head" = <head> tag, "body_start" = after <body>, "body_end" = before </body>. Default: head. |
| priority | integer | No | Load order priority (1-10, lower = earlier). Default: 1. |
| status | string | No | Post status. "publish" = active immediately, "draft" = saved but not active. Default: publish. |
| ensure_jquery | boolean | No | If true, ensures jQuery is loaded before this snippet runs. Default: false. |
Returns
Returns snippet_id, title, location, priority, status, and edit_url.
Permission
check_snippet_permission requires both manage_options and unfiltered_html capabilities.
More The Plus Addons for Elementor abilities
Accordion
Adds The Plus Addons "Accordion" widget (tp-accordion) to an Elementor container.
Add Container
Adds a new Elementor flex container to a page or nests it inside another existing container.
Add Container
Adds a flex or grid container to a page, optionally nested inside a parent container.
Add Custom CSS
Adds custom CSS to a specific element or to the entire page (requires Elementor Pro).
Add Custom JavaScript
Adds a custom JavaScript snippet to a page by inserting an HTML widget containing a <script> tag; works with free Elementor.
Add Stock Image
Searches Openverse for an image, downloads it to the Media Library, and adds it as an image widget to the page in one step.