admin管理员组

文章数量:1122846

The following code updates the post status of standard wordpress posts to 'Archived'.

UPDATE wp_posts SET post_status = 'Archived' WHERE post_status != 'static';

How can I make this only affect custom post types with the slug of 'cpt_operator'. I know I can do this from Wp-Admin but with over 2,500 posts its a huge task.

The following code updates the post status of standard wordpress posts to 'Archived'.

UPDATE wp_posts SET post_status = 'Archived' WHERE post_status != 'static';

How can I make this only affect custom post types with the slug of 'cpt_operator'. I know I can do this from Wp-Admin but with over 2,500 posts its a huge task.

Share Improve this question asked Nov 9, 2016 at 12:01 JamesJames 2483 silver badges14 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

If you mean post type instead of slug I'd say...

UPDATE wp_posts
SET post_status = 'archived'
WHERE post_status <> 'static'
AND post_type = 'cpt_operator';

But be careful when editing the db directly!

Use this to delte posts with time line:

UPDATE `wp97_posts` SET post_status="archive" WHERE post_date < '2023-05-30 19:15:27' AND post_status="publish";

本文标签: databaseBulk Update of Custom Post Type Post Status through SQL