wp_set_custom_code
Inject site-wide CSS and/or JavaScript on every page. ONE snippet carries both: put CSS in a block and JS in a block in the same code body. Use this for anything the brand kit's design tokens cannot express — backdrop-filter, clip-path, layered shadows, @keyframes animation, scroll/sticky behaviour, analytics and third-party embeds. name is the IDEMPOTENCY KEY: re-pushing the same name UPDATES that snippet, so a re-run cannot stack duplicates that all inject at once. CHANGES EVERY PAGE — pass confirm=true. READ rendered IN THE RESPONSE, NOT THE STATUS CODE: the connector fetches the front page and reports whether the code actually reached the HTML, so a snippet that saved but never rendered comes back rendered=false with a hint instead of looking like success. The XeoRank Connector injects these itself on wp_head / wp_body_open / wp_footer, so it needs NO Elementor Pro and works on any theme — but it also means the snippets live in XeoRank, not in Elementor's Custom Code UI. Requires Connector v0.9.2+. CHOOSING THE RIGHT HOME: this renders on the frontend, but CSS that must show inside the Elementor editor CANVAS belongs in wp_set_brand_kit(custom_css); CSS scoped to one element belongs in wp_patch_page(style.custom_css). Prefer brand-kit TOKENS over CSS whenever a token can express it — tokens stay editable in the UI, CSS does not.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Raw markup to inject. May contain <style> and/or <script> blocks. Not escaped — send it exactly as it should appear in the page. | |
| name | Yes | Snippet name, e.g. 'XeoRank — global CSS'. Also the idempotency key: re-using it updates that snippet in place. | |
| status | No | 'publish' (default, live) or 'draft' (saved, not injected) | |
| verify | No | Check the code really rendered on the front page. Default true — leave it on. | |
| confirm | No | Must be true to apply — without a narrower `conditions`, this injects on every page | |
| site_id | Yes | WordPress site id (from list_wordpress_sites) | |
| location | No | Where to inject: 'head' (default; critical CSS, meta, tracking), 'body_start', or 'body_end' (non-critical JS, avoids render-blocking). | |
| priority | No | 1-10, default 10 (rejected with an error outside that range, never silently clamped). LOWER runs earlier when several snippets share a location. | |
| conditions | No | Elementor display conditions. Defaults to ['include/general'] (entire site) — an empty set would inject nowhere. When this site falls back to XeoRank's own injector (injected_by:'xeorank-connector' in the response) only these shapes are actually enforced: 'include/general', 'include/singular/front_page', 'include/singular/page', 'include/singular/page/<id>', 'include/singular/post', 'include/singular/post/<id>'. Any other shape (archive/taxonomy/exclude conditions) matches nothing on the fallback path — use one of the shapes above to scope a snippet to one page/post there. |