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

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.

  • 1
    Ah, good one. I automatically assumed the question was about code. :) – montrealist Jul 17 '17 at 13:00
  • @montrealist, I'm not really sure. :) The question is too thin. – Max Yudin Jul 17 '17 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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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