最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

content - How to retrieve text only from a post using WP CLI?

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论