What am I doing wrong creating post draft via wp-cron? (wp_schedule_event & wp_insert_post)

The problem is that you’re only hooking the cron action on admin_init, which doesn’t run when wp-cron.php is called. So the function will never run. So this function shouldn’t be inside wpcp_activate(): add_action( ‘wpcp_cron_hook’, ‘wpcp_cron_do’ ); Also, register_activation_hook() shouldn’t be inside the admin_init hook either. So your code should look like this: function wpcp_make_post( $post_title, … Read more

Hook when post is set from published to draft?

Yes, these are probably the right calls to use for what you want. I just checked this by adding this to my functions.php: add_action(‘publish_to_draft’, ‘doStuff’); function doStuff() { update_option(‘foo’, ‘bar1’); } Then using the quick edit in the posts list to change a published post to draft, and this hook definitely ran at that point … Read more

How to change my 3000 Published post status to Draft using PHPMyAdmin

If you have access to phpMyAdmin you can run this SQL query directly: UPDATE {prefix}posts SET post_status=”draft” WHERE post_status=”publish” If you do not have any experience with SQL queries then you should use this solution. Just place this code in functions.php and refresh the WordPress once, and it will be done. function setPostsToDraft() { global … Read more