Edit a theme file
edit_theme_fileModify specific parts of a WordPress theme file with targeted find/replace edits, leaving the rest untouched. Fails if no match is found to prevent silent errors.
Instructions
Make targeted find/replace edits inside a theme file, leaving the rest untouched. Safer than write_theme_file for changing one function or block of markup. An edit that matches nothing fails loudly rather than silently writing nothing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path relative to the theme root. | |
| edits | Yes | Edits applied in order. | |
| theme | No | Theme stylesheet or draft id. | |
| site_id | No | Which configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids. | |
| allow_live_theme | No | Permit editing the live active theme directly. Use a draft instead. |