wp_replace_shortcode
Replace a specific shortcode on a WordPress page with new content. Optionally filter by attribute and preview changes before applying.
Instructions
Find a specific shortcode in a page and replace it with new content. Optionally match an attribute value.
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": {
"page_id": "<page_id>",
"tag": "<tag>",
"new_shortcode": "<new_shortcode>"
},
"name": "wp_replace_shortcode"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | Yes | Shortcode tag to find | |
| dry_run | No | Preview changes without writing | |
| page_id | Yes | Page ID | |
| match_attr | No | Attribute used to disambiguate | |
| occurrence | No | Zero-based occurrence after tag/attribute filtering | |
| match_value | No | Required substring in the attribute | |
| new_shortcode | Yes | Full replacement shortcode string |