How do I add a post status option to delete the post instead of setting it to draft or pending or anything like that?
2 Answers
You can move the post to Trash before you save it or publish:
Or you can do it later, from the post list:
Later you can empty Trash or it will automatically delete everything from Trash what is older than a month.
-
1Ah, good one. I automatically assumed the question was about code. :) Jul 17, 2017 at 13:00
-
You can set the post status to trash
.
$post_id = 1; // change this to your post ID
$status = 'trash';
$current_post = get_post( $post_id, 'ARRAY_A' );
$current_post['post_status'] = $status;
wp_update_post($current_post);
Got code from this answer.
-
So you can set post status to trash and it will move it to the trash? Jul 16, 2017 at 21:16
-
-
Feel free to mark the answer as accepted if it ends up working for you. ;) Jul 17, 2017 at 12:59