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 questionI 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
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 questionI 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
- 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
1 Answer
Reset to default 3I 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
评论列表(0条)