Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Created December 15, 2016 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/06246065be487e3c7085ce5d8615beef to your computer and use it in GitHub Desktop.
Save SiR-DanieL/06246065be487e3c7085ce5d8615beef to your computer and use it in GitHub Desktop.
/**
* Handles the bulk action.
*/
function my_bulk_action_handler( $redirect_to, $action, $post_ids ) {
if ( $action !== 'draft_posts' ) {
return $redirect_to;
}
foreach ( $post_ids as $post_id ) {
wp_update_post( array(
'ID' => $post_id,
'post_status' => 'draft',
) );
}
$redirect_to = add_query_arg( 'bulk_draft_posts', count( $post_ids ), $redirect_to );
return $redirect_to;
}
add_filter( 'handle_bulk_actions-edit-post', 'my_bulk_action_handler', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment