I’m working on a plugin that changes a posts status (draft / published) based on its meta data.
While there is a handy function to get a posts current status:
I can’t find any record of a similar function to allow you to set the status.
I’m currently using a custom DB call (below) but I’m worried that other crucial function calls are not happening!
$wpdb->update( $wpdb->posts, array( 'post_status' => 'draft'), array( 'id' => $id ), array( '%s' ), array( '%d' ) );
Does any one know a better way to achieve this please?
- The topic ‘set_post_status() function?’ is closed to new replies.