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

Write

Creates 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.

Newsletter

The AI + WordPress space moves fast. Keep up.

New tools, workflow ideas, and product updates — be the first to know what's next.

No spam, unsubscribe anytime.