Edit post text
wp_alter_postFind and replace text inside one field of a post (for example its content), without sending the whole content again. Supports regular expressions with regex set to true and modifiers in flags.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ID | Yes | Post ID. | |
| field | Yes | Field to modify: post_content, post_excerpt, or post_title. | |
| flags | No | Optional PCRE modifier letters applied in regex mode, e.g. "i" (case-insensitive), "s" (dotall), "m" (multiline). Allowed: i, m, s, x, u, A, D, S, U, X, J. | |
| regex | No | Treat search as a regex pattern (default: false). | |
| search | Yes | Text to search for, or (with regex=true) a bare PCRE pattern without delimiters, e.g. <!-- /wp:paragraph -->\s*$ | |
| replace | Yes | Replacement text. In regex mode, backreferences like $1 / \1 are supported. |