I want to change the status of already publish post to draft using its id.
add_action( 'save_post', 'change_post_status', 1 );
function change_post_status( $post_id ){
$my_post = array(
'ID' => 1,
'post_status' => 'draft',
);
// unhook this function so it doesn't loop infinitely
remove_action('save_post', 'change_post_status');
wp_update_post( $my_post );
// re-hook this function
add_action('save_post', 'change_post_status');
}
I want to change the status of specific post which has id = 1 to be changed to draft.This is what I have tried and not got success . Neither I am getting any error, Can I do something to know if it is firing or not ? and how I can do it ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire