Simply check if the event is scheduled, and if not, schedule it:
add_action(
'init',
function () {
if ( ! wp_next_scheduled( 'my_scheduled_event' ) ) {
wp_schedule_event( time(), 'hourly', 'my_scheduled_event' );
}
}
);
Related Posts:
- Which action for triggering cron “wp”or “init”?
- wp_schedule_event in a class
- WP Cron – Run Cron after evey 15 minutes at a specific time for the next three hours
- Using wp_cron with custom time interval and the register activation hook
- WordPress scheduled task is called but not executed
- Problem creating cron job wordpress
- How Do I Make WordPress Run an Event Every Day?
- How can I change the frequency of a scheduled event?
- Hourly WP schedule, do I need at least 1 visitor hourly?
- WP Cron doesn’t save or in post body
- Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?
- WordPress cron running twice
- Scheduling a task using class methods
- What is minimum time interval for which a cron be scheduled?
- Will cron job run if page loaded is being served from cache?
- Use wp_set_post_terms() instead of wp_insert_post()
- Programmatically detect if wp-cron is disabled?
- How to schedule a cron job in plugin without waiting for page load request?
- How to perform a heavy and long process in cron jobs?
- WordPress daily cron is executing more frequently than once a day
- wp-cron and execution of code in is_admin() included script
- How to Trigger WP CRON at Local Timestamp?
- WP Cron being triggered but not working as expected
- wp_schedule_event() set daily, but processed every second
- Will I get an error if I try unscheduling a WP Cron scheduled task that wasn’t scheduled?
- WordPress plugin cron working only if admin is logged in
- How to make a cronjob type plugin
- wp_schedule_single_event is set correctly but sometimes not fired
- How to Run Plugin on Server Without Web Browser
- Plugin with functions inside a class & how to trigger WP CRON
- Custom recurrence not working / Wp Cron event
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- WP Cron as Fast as WordPress AJAX?
- Detect each active instance of a widget
- What is the use of wp_schedule_event hook?
- Can wp_schedule_single_event be used to run background proccess?
- Call do_action() within WordPress cronjob
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- wp cron does not run when i am not logged in to wp admin
- Correct way to enqueue jquery-ui
- How to echo the_excerpt without the P tag wrapper?
- How can I update a wordpress plugin from a Git repository (github)
- Is There a Plugin Life Cycle Documentation?
- What is an alternative method to the WordPress private _doing_it_wrong() function
- Shortcode adding p and br tags
- Problems with localization
- Install and load additional plugins when running unit tests
- Having Problem On Getting WP Post Gallery Images URL
- How do I hook a custom discount to change a WC_Order price total on WooCommerce?
- Properly licensing a plugin that uses Apache 2.0 licensed code
- Can I dynamically create a link to my plugin settings/options page from my plugin description?
- How to load the plugin only when logged in?
- Cannot search post by taxonomy
- Hook into theme-switching later than `setup_theme`
- Will current_theme_supports return TRUE with a nonstandard add_theme_support?
- WP AJAX is not working, always returns 0
- Act on user meta updated, but only once
- get_pages Drop down list for selection of a page
- Admin auto-refresh is interfering with Firebug — how to prevent it?
- How do I add custom column to woocommerce cart?
- WordPress mode for emacs?
- Widget translation on my plugin
- Upload to a remote server using wp_remote_post
- Make WordPress cache permanent for some pages until edited
- conditionally load javascript & CSS for do_action() calls from plugin
- The plugin does not save data
- How do I create plugin or theme using MVC pattern?
- tinymce.get() returns error after ajax request
- Access bloginfo, get_option, and plugins_url from a non-core php file
- How to get a list of child ids for a named category?
- Plugin could not be activated because it triggered a fatal error, unexpected ‘[‘
- How to make the first commit on WordPress.org
- How best to handle database version dependence (from $wp_db_version)
- Why aren’t some plugin styles loading when I load a template?
- Pagination not working with custom wp_query
- Remove Permalink Meta Box not working?
- WordPress actions for plugin admin UI page
- wp_insert_user keeps echoing values
- Pause plugin option page until all data manipulation is complete
- Modify custom block plugin without losing content
- apply_filters() and call_user_func() to define and call a function outside a class
- How to show only the last two categories in a menu?
- HTML Elements in my WP Plugin being generated in JS. Security and Translated Text Question about this method being used
- howTo let wordpress endpoint return html-page
- User meta query using Wildcard
- wp_ajax add_action fuction won’t fire on custom jQuery action
- wordpress4.8.2 Multilingual Plugin
- Dedicated server and WPDB Class : huge slow-down of the website
- Create dedicated page with custom template showing custom data
- How can I see a varibles value when my plugin runs?
- Add Button to TinyMCE Custom Menu
- How should I use wpdb class to submit a form in admin dashboard?
- WordPress plugin: admin-ajax.php not passing data to custom function
- Create pages for authors
- How do I create Widget within plugin that uses its own class?
- How to design WooCommerce-like admin tabs for plugin settings page?
- Woocommerce: block user removing cart item
- How can I dynamically change title and description in WordPress?
- Return custom product in ajax call loop
- Is using upgrader_process_complete the correct way to perform plugin updates?