Only Showing Upcoming Events

Hi @Spencer B.: Funny, my client submitted a bug ticket for the events modules I wrote for this very issue the other day, and I just fixed it a few hours ago. Note that my example uses a Custom Post Type of ‘event’ which is very useful to be able to differentiate logic for Events … Read more

trigger save_post event programmatically

It’s wp_insert_post() vs. wp_update_post() – where update will ultimately also call: return wp_insert_post( $postarr, $wp_error, $fire_after_hooks ); The term “once” implies that it is being fired “afterwards”. /** * Fires once a post has been saved. * * @since 1.5.0 * * @param int $post_ID Post ID. * @param WP_Post $post Post object. * @param … Read more

Scheduled events disappear from events queue

My solution for now is check every hour if it is running and if not reschedule it. I also remove this in deactivate etc. wp_schedule_event(time(), ‘hourly’, ‘my_restart_schedule_if_failed’); function my_restart_schedule_if_failed() { if( !wp_next_scheduled( ‘my_scheduled_minute_job’ ) ) { wp_schedule_event( time(), ‘one_minute’, ‘my_scheduled_minute_job’ ); } }

How to set a custom post type to have viewable future posts

I’ve been able to solve this myself. My entire code for registering the CPT: <?php add_action( ‘init’, ‘events_post_type_register’ ); function events_post_type_register() { $post_type = “events”; $labels = array( ‘name’ => _x(‘Events’, ‘post type general name’, ‘project_X’), ‘singular_name’ => _x(‘Event’, ‘post type singular name’, ‘project_X’), ‘add_new’ => _x(‘Add New’, ‘event’, ‘project_X’), ‘add_new_item’ => __(‘Add New Event’, … Read more

WordPress Media Uploader events

I don’t think there is. You will have to use some local (browser-based) Javascript code to attach a function to the on-click event of the button. (Not a Javascript expert, but perhaps this will point you in a direction of investigation.)

WP Cron Doesn’t Execute When Time Elapses

First can you please confirm that you don’t have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page. If you have a caching plugin enabled, you can choose one of your pages, add an exclussion to your … Read more

How to run a function every 5 minutes?

You can create new schedule times via cron_schedules: function my_cron_schedules($schedules){ if(!isset($schedules[“5min”])){ $schedules[“5min”] = array( ‘interval’ => 5*60, ‘display’ => __(‘Once every 5 minutes’)); } if(!isset($schedules[“30min”])){ $schedules[“30min”] = array( ‘interval’ => 30*60, ‘display’ => __(‘Once every 30 minutes’)); } return $schedules; } add_filter(‘cron_schedules’,’my_cron_schedules’); Now you can schedule your function: wp_schedule_event(time(), ‘5min’, ‘my_schedule_hook’, $args); To only schedule … Read more

How to test wp_cron?

My favorite plugin for that is Core Control which has very nice module for display of what is going in the cron – which events are set up, when are they next firing, etc. On getting your hands dirty level see _get_cron_array(), which returns internal stored data for cron events (top level of keys are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)