0

How do I add a post status option to delete the post instead of setting it to draft or pending or anything like that?

1

2 Answers 2

1

You can move the post to Trash before you save it or publish:

enter image description here

Or you can do it later, from the post list:

enter image description here

Later you can empty Trash or it will automatically delete everything from Trash what is older than a month.

2
  • 1
    Ah, good one. I automatically assumed the question was about code. :) Commented Jul 17, 2017 at 13:00
  • @montrealist, I'm not really sure. :) The question is too thin.
    – Max Yudin
    Commented Jul 17, 2017 at 13:26
0

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.

3
  • So you can set post status to trash and it will move it to the trash? Commented Jul 16, 2017 at 21:16
  • It should, yes. Commented Jul 16, 2017 at 21:26
  • Feel free to mark the answer as accepted if it ends up working for you. ;) Commented Jul 17, 2017 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.