customization - Best way of deletion of old posts

Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 5 years ago.

Improve this question

I have a few sites that I wish to slim down. The sites have been active for a long time and there is really old post data that is no longer relevant. I wish to delete those (older then 3 years) and there meta data, their attached media, revisions and including W3 cache files. Also a database cleanup can help a bit.

Which method is best?
1. Plugin 'Bulk delete' with pro addon delete 'delete attachment'
2. wp-cli post delete
3. WP api function

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 5 years ago.

Improve this question

I have a few sites that I wish to slim down. The sites have been active for a long time and there is really old post data that is no longer relevant. I wish to delete those (older then 3 years) and there meta data, their attached media, revisions and including W3 cache files. Also a database cleanup can help a bit.

Which method is best?
1. Plugin 'Bulk delete' with pro addon delete 'delete attachment'
2. wp-cli post delete
3. WP api function

Share Improve this question edited Jun 20, 2019 at 8:57 norman.lol 3,2313 gold badges30 silver badges35 bronze badges asked Jun 20, 2019 at 7:22 zebrastribezebrastribe 517 bronze badges 5
  • Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. Choose what fits YOU best. – norman.lol Commented Jun 20, 2019 at 8:29
  • 1. Costly addon with yearly billing seems a bit much 2. Seems like a good solution with a bit of a leaning curve. Could a solution be like: wp post delete $(wp post list) ref: developer.wordpress/cli/commands/post/delete is data_query before parameter support as for wp_query? developer.wordpress/reference/classes/wp_query/… or just the 'AVAILABLE FIELDS' in developer.wordpress/cli/commands/post/list 3. Need a bit of extra work – zebrastribe Commented Jun 20, 2019 at 8:52
  • 1 Working on the wp-cli solution, thanks Leymanx :-) There seems to be a limit of a 1000 posts when using the 'before' and 'after' github/wp-cli/wp-cli/issues/3039 So the command would be only work for one year at the time but look like this: wp post delete $(wp post list --post_type=post --format=ids --year=2008) @leymannx, is this correct? – zebrastribe Commented Jun 20, 2019 at 9:32
  • This looks good. I'd always prefer wp-cli as well for stuff like this. Better test it on a local copy of your site first. – norman.lol Commented Jun 20, 2019 at 10:33
  • Great, also if the argument gets to long I will use '--posts_per_page=10000': ericbusch/… wp post delete $(wp post list --post_type=post --format=ids --year=2008 --posts_per_page=10000) Do you know if the media, comments and meta data associated with the deleted posts also gets deleted? – zebrastribe Commented Jun 20, 2019 at 10:54
Add a comment  | 

1 Answer 1

Reset to default 3

I will use the wp-cli version:
wp post delete --force $(wp post list --post_type=post --format=ids --year=2008 --posts_per_page=10000)

I added the --force so that it will delete the post and not just put them in the trash.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745381810a4625263.html

相关推荐

  • customization - Best way of deletion of old posts

    Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信