By Fahad Murtaza · Published · Updated
Add custom CSS and code snippets with your AI agent
Sometimes the fastest fix is a few lines of CSS, or a tracking snippet in the head. WP MCP gives your AI agent both, and the CSS path works on any site, not just Elementor Pro.
What you need
- WP MCP installed and connected to your AI client, with its Pro tier active.
- For custom CSS: nothing else. It uses WordPress core Additional CSS, so it works on every site.
- For code snippets: Elementor Pro’s Custom Code renders them. WP MCP stores and manages them on any site, and they run once Pro is active.
Add site-wide CSS
› Add CSS to make all H2 headings dark blue.
› Replace the custom CSS with this block instead.
add-custom-css appends to your site’s Additional CSS by default, or replaces
it with replace: true. Because it writes through WordPress core, the CSS
applies site-wide regardless of your builder, and the change is snapshotted, so
get-custom-css shows you the current state and any edit is reversible.
Manage code snippets
› Add a snippet that prints my analytics tag in the head.
› List all my code snippets.
› Delete the old chat-widget snippet.
create-code-snippet stores an Elementor Custom Code snippet with its location
(wp_head, wp_body_open, or wp_footer) and priority. list-code-snippets
shows what you have, and delete-code-snippet trashes one reversibly.
Why it is safe
Custom CSS is captured by WP MCP’s snapshot before every write, so a styling change is one click from undone. Code snippets are ordinary posts, created and trashed reversibly, so nothing you add is permanent unless you want it to be.
Common questions
Can AI add custom CSS to WordPress without Elementor Pro?
Yes. WP MCP writes site-wide CSS through WordPress core Additional CSS, so it works on any site and any builder, with or without Elementor Pro. The add-custom-css tool itself is a WP MCP Pro tool, and Elementor Pro is only needed for Custom Code snippets to actually render.
Does the add-custom-css tool append or replace my existing CSS?
By default it appends to your Additional CSS. Pass replace: true and it replaces the existing CSS with the new block.
Can I undo a custom CSS change made by an AI agent?
Yes. When your site already has Additional CSS, the change is snapshotted before it is written, so rollback-operation can restore it, and get-custom-css shows the current state at any time.
How do I add a tracking script to my site head with AI?
Ask the agent to add a code snippet and WP MCP stores it as an Elementor Custom Code snippet. Script injection is off by default: the site owner must enable it with WPMCP_ALLOW_JS_INJECTION or the wpmcp_allow_js_injection filter, and the connected user needs unfiltered_html. The snippet runs once Elementor Pro is active, and you can list or delete snippets later by asking.
Do custom CSS and code snippets need WP MCP Pro?
Yes. add-custom-css, get-custom-css, create-code-snippet, list-code-snippets and delete-code-snippet are all WP MCP Pro tools.
All WP MCP guides, or see every plugin integration. Topic: Elementor.