Replace Text in a Custom Field


Changes one passage of text inside a single custom field, leaving the rest of the value untouched. This is how to edit text that a page builder stores outside the post body. For Elementor pages prefer the Elementor abilities, which edit the layout through its own structure and cannot mistake a setting for visible text; use this when those cannot reach what you need. Refused outright when the value is PHP-serialized, or when the change would break JSON that is currently valid.

Also known as: find and replace in custom fields, edit post meta text, change builder text.

Property Value
Ability slug mosmcp/content-replace-in-meta
Wire tool name mosmcp__content-replace-in-meta
Category Content Editing (mosmcp-content-editing)
Plan Free

 

Required access

Requirement Value
Capability edit_post (checked against the specific post)
Minimum default role Contributor
Annotations readOnly: false · destructive: false · idempotent: false · openWorld: false

 

Input schema

Field Type Required Default Description
post_id integer (min 1) Yes — The ID of the post that holds the field.
meta_key string Yes — The name of the custom field to edit.
find_text string Yes — The existing wording to replace. Get this from mosmcp/content-find-in-meta.
replace_with string Yes — The new wording. Pass an empty string to delete the found text. HTML is saved the way the WordPress editor saves it: a user with the unfiltered_html capability can save any markup, including forms, scripts and styles, and markup a user is not allowed to save is refused with the reason rather than silently removed. Backslashes are kept.
replace_all boolean false Change every occurrence instead of requiring exactly one.

 

Output schema

Field Type Required Description
target string Yes What was edited, for example "post 12 post_content".
changed boolean Yes
occurrences integer Yes How many occurrences were replaced.
match_mode string How the text was matched. Anything other than "exact" means the stored wording differed from what was asked for, so the result is worth checking.
length_before integer
length_after integer
stored_verbatim boolean False when the site altered the text on the way in, which means the stored value now differs from what was sent.
notes string[]

 

Example

Sample prompt
Change 'Established 2010' to 'Established 2009' in the About page's hero subtitle field.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 154,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__content-replace-in-meta",
    "arguments": {
      "input": {
        "post_id": 18,
        "meta_key": "hero_subtitle",
        "find_text": "Established 2010",
        "replace_with": "Established 2009"
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 154,
  "result": {
    "isError": false,
    "structuredContent": {
      "target": "post 18 field \"hero_subtitle\"",
      "changed": true,
      "occurrences": 1,
      "match_mode": "exact",
      "length_before": 42,
      "length_after": 42,
      "stored_verbatim": true,
      "notes": []
    }
  }
}

 

Edge cases / errors

  • PHP-serialized value → mosmcp_serialized_value; nested-JSON builder fields → mosmcp_nested_json_refused; non-text value → mosmcp_meta_not_text.
  • Change would turn valid JSON invalid → mosmcp_json_would_break; nothing is written.
  • Field the account may not write → mosmcp_meta_protected; several matches without replace_all → mosmcp_multiple_matches.
  • After the write, builder CSS caches are refreshed so the change shows.

 


<< Previous Next >>
Find Text in Posts Replace Text in a Post

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.