wordpress function to change post status [duplicate]

I guess it should work . As long as $id is available things are easy.

<?php
if (empty($items)) {
$ret .= " 'No new videos.'";
$postid = $post->ID; //Supply post-Id here $post->ID.
    wp_update_post(array(
        'ID'    =>  $postid,
        'post_status'   =>  'draft'
        ));
}
else
    foreach ( $items as $item ) :
?>

Give it a shot.

Leave a Comment