We have a custom post type with over 16.000 posts in database. Each post has a custom meta data 'expiry date'.
We want to regularly delete old posts that have: 1. Expiry date older dan 2 years AND 2. are not visible on our website
Some 'expired' posts are still shown and I want to make sure these do not get deleted.
We have a custom post type with over 16.000 posts in database. Each post has a custom meta data 'expiry date'.
We want to regularly delete old posts that have: 1. Expiry date older dan 2 years AND 2. are not visible on our website
Some 'expired' posts are still shown and I want to make sure these do not get deleted.
Share Improve this question asked Nov 25, 2019 at 12:40 LoyensLoyens 134 bronze badges1 Answer
Reset to default 0I suggest you use MySQL "DELETE". See this article:
http://www.mysqltutorial/mysql-delete-join/
So, something like this:
DELETE wp_posts, wp_postmeta
FROM wp_posts
INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
WHERE meta_key = 'expiry date' AND meta_value <= '2017-11-27' AND post_status != 'publish'
NOTE: 'wp_' could be different depending what your table prefix is set to in your wp-config.php file.
This should get rid of all posts in the posts table and all of the meta records in the meta table. It will also get rid of drafts/revision.
DOUBLE NOTE: -SUPER IMPORTANT- Don't do this unless you have a backup of your database.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744964035a4603564.html
评论列表(0条)