I have the post ids and urls. I need to extract the post content make some modifications and update again. I have more than 2,000 posts hence I would like to do it using WP CLI and not manually. Can I know how do I do that?

EDIT : I need to take the entire text and -

  1. change the fonts. Remove some html tags.
  2. add some internal links.
  3. Append with a link to our facebook and twitter page.
  4. Include a Ad code.

For all posts

  • What kind of modifications? Please add more detail. wp-cli can e.g. handle search and replace.
    – birgire
    Aug 9, 2019 at 15:33
  • @birgire I have made the edits. Have added more details
    – Trect
    Aug 9, 2019 at 15:51

1 Answer 1


Changing fonts and stripping tags can be done with a mySQL query. You'll just need to figure out the right regexes to search and replace.

For everything else, it sounds like you would be better off updating the single.php template. Social links, ad codes, all those sorts of things are better managed in a single place so that if they ever change, you can update them once and you're done. You can also more easily segment that part of the code outside of the main content, which ideally is in a <main> tag, so that search engines and assistive technology recognize which parts are templated and what part is the actual unique content of a page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.