wp_update_custom_css
Updates WordPress Additional CSS for the active theme. Default mode=replace accepts complete css and returns before/after CSS. For small changes, read wp_get_custom_css with source=persisted, then use mode=edit with oldText/newText and the returned scope and fingerprint. Matching is exact, not fuzzy. Insert by replacing an anchor with anchor plus new text; delete with empty newText. Edit returns compact observed metadata. Requires confirm=true after user approval. Conflict detection is best-effort, not atomic. Never retry automatically after a lost response.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"site_id": "<site_id>",
"confirm": "<confirm>"
},
"name": "wp_update_custom_css"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| css | No | Required in replace mode: complete replacement Additional CSS contents. | |
| mode | No | Defaults to replace. Edit requires oldText, newText, stylesheet, parent_post_id, and expected_current_sha256; css is not allowed. | |
| confirm | Yes | Must be true after the user approves changing persistent site CSS. | |
| newText | No | Edit only: literal replacement text, different from oldText. Empty string deletes. | |
| oldText | No | Edit only: nonempty exact text to replace. Must match once unless replaceAll=true. | |
| site_id | Yes | The connected site's id returned by list_sites. Call list_sites first; do not use a URL or WordPress post ID. | |
| replaceAll | No | Edit only: replace all non-overlapping exact occurrences. Defaults to false. | |
| stylesheet | No | Theme stylesheet slug. Required in edit mode, optional in replace mode. Must match the active stylesheet. | |
| parent_post_id | No | Edit only: current Custom CSS post ID from wp_get_custom_css. | |
| expected_current_sha256 | No | Edit only: persisted_css_sha256 from the prior read. Best-effort conflict detection, not an atomic lock. |