admin管理员组

文章数量:1416651

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

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

Share Improve this question edited Aug 9, 2019 at 15:50 Trect asked Aug 9, 2019 at 14:54 TrectTrect 1537 bronze badges 2
  • What kind of modifications? Please add more detail. wp-cli can e.g. handle search and replace. – birgire Commented Aug 9, 2019 at 15:33
  • @birgire I have made the edits. Have added more details – Trect Commented Aug 9, 2019 at 15:51
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: contentHow to retrieve text only from a post using WP CLI