Change a Post’s Status based on the date from a custom field? (for Event posts)

There are several little issues with your code. This is what I use for the exact same thing though and it works: // expire events on date field. if (!wp_next_scheduled(‘expire_events’)){ wp_schedule_event(time(), ‘daily’, ‘expire_events’); // this can be hourly, twicedaily, or daily } add_action(‘expire_events’, ‘expire_events_function’); function expire_events_function() { $today = date(‘Ymd’); $args = array( ‘post_type’ => … Read more

posts stuck as drafts

You probably have some custom functions in your themes functions.php Add a return; on top of this file. If the problem is solved: Move it below the first function. Proceed this way until you’ve found the function that is causing the problem. If this doesn’t work: Go and do the same for one template file … Read more

Do anything on post_status change [duplicate]

Wrong search terms, already found it: function on_all_status_transitions( $new_status, $old_status, $post ) { if ( $new_status != $old_status ) { // A function to perform actions any time any post changes status. } } add_action( ‘transition_post_status’, ‘on_all_status_transitions’, 10, 3 ); https://codex.wordpress.org/Post_Status_Transitions