A simple and dynamic way to use WordPress cron would be to set up an action hook for your schedule then only add scheduled events as and when you need them. The events would call a generic function and pass in your specific custom post type details through $args –
add_action('my_schedule_event', 'generic_function');
function set_schedule($post_id) {
$time = strtotime(date('Y-m-d H') . ':00:00');
$args = array('post_id' => $post_id);
wp_schedule_event( $time, 'hourly', 'my_schedule_event', $args);
}
function generic_function($post_id) {
// do your thing
}
So in lmk_alter_method_name() you call set_schedule($post_id).
Hope that helps!
Related Posts:
- Running WordPress on the Command Line – Turn off Delayed Output?
- How is WP Cron Locking implemented?
- Better handling of WP-CRON server load abuse
- When does next Cron Job run (time from now)?
- run a cron task without obstructing page load?
- Recurring scheduled task help
- How to make wp cron job not fire immediately?
- Trigger a cron every 24h GMT -8
- WordPress Cron Schedule the if and else statement
- Schedule event every second thursday of the month
- How do i schedule cron in wordpress for each second?
- WP Cron job every 1st and 15th of the month
- Template Tag not available in real Cron Jobs
- WordPress Caching – Transients API or “update_user_meta ” Cronjob?
- WP CRON on shared hosting that does not allow loopback connections?
- Is it possible to use `wp_schedule_event` with real cronjobs?
- How to use wp cron job to run a function
- Are uploads directories created on a schedule?
- WordPress can’t seem to handle tens of thousands of scheduled posts? Cron Breaks
- What is the curl error 52 “empty reply from server”?
- How to test wp_cron?
- How to debug WordPress “Cron” wp_schedule_event
- Check if function called by cron job
- Wp_Schedule_Event every day at specific time
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- Delete all scheduled events with a particular hook
- wp-cron.php – How are WP’s Cron transients removed?
- Need to execute a cron job
- crontab wp-cron.php on multisite path-based network: one for each path? Or just one for the root?
- Running wp-cron from CLI
- How Do I Make WordPress Run an Event Every Day?
- get_posts inside cron
- Initialize WordPress environment to use in a real cron script
- Cron jobs for deactivated plugins
- WP Cron emails not working
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- Check if event was scheduled – schedule event only once
- How do I get a Function in my functions.php to execute with a cron job?
- How to notify the admin about something that happened during a cron job
- Cronjob returns a lot of REMOTE_ADDR, SERVER_PORT, SERVER_NAME, etc errors
- Create function in functions.php with hook name to execute URL
- How to remove unused avatar uploads in buddypress [closed]
- cron.php being constantly deleted [closed]
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- Insert WordPress page via external (cron) script?
- Detect if Cron is Running
- Set a menu item to display during certain times
- Run function with linux cron job in WordPress
- Schedule cron don’t work
- Auto Publish On Cron
- How to use a class within a cron job function
- Can a scheduler be set on submit of a form in wordpress?
- WordPress Cron Job in Bookly Plugin [closed]
- Can you register two cron events in a single function?
- When to use wp_schedule_single_event for async / non-blocking processes?
- Does using WP-cron make the site slower for the user?
- System Cron job not firing
- WordPress Cron Job Not working
- running wp-cron.php using php not wget
- WordPress automatic publish: is there a timeout when WordPress won’t publish anymore?
- wp cron job fires at every second or so, if callback is wrapped with DOING_CRON check it never fires at all
- Cancel/Stop a currently ongoing scheduled cron event?
- WordPress function, Run using Crontab
- Interrupted cron script sending me hourly emails. Please help!
- Scheduling WP cron jobs
- Switch from wp-cron to a server cron job
- WordPress cron is running with previously set time intervals and not the updated one
- is WGET correct for this cron job?
- How can I prove if wp cron is running my task if I have DISABLE_WP_CRON set to true
- Best Way to Enter Maintenance Mode Programmatically
- Set up a WP Cron scheduled event to update calculated ACF field
- WP Cron Working, but Function Not Working
- Solution for processing lots of data with CRON/API, dealing with memory/timeout issues
- Strange cron job behavior and how to solve it?
- WordPress cron not getting executed when called by external service (but ok from browser)
- Bulk updating a group of WordPress Pages every 10 minutes
- Cron job to change CPT
- Setting up a cron job to auto update a custom field
- Is there a delay to include call function modification in a scheduled cron task?
- How to pass variable from other function?
- How to Set a Condition via Page Template Name in WP Cron Job?
- Server cron job not working
- wp-cron event doesn’t run when custom login API is enabled
- CRON job to update wp_usermeta value each day or week based on server time
- Php cron job (wp-cron) not working
- Call a PHP file from Cronjob
- unix cronjob for wordpress does not stop running
- Run external file cron using WordPress Scheduler
- Better way to run heavy scripts using WordPress database
- does wordpress auto update work without a cron job?
- Pages for Cron use Only?
- Does DISABLE_WP_CRON prevent plugins from registering new cron tasks?
- Cronjob function not executed – negative seconds
- WP CRON Fails At 13:00 Every Day
- Running a cron job manually and immediately
- Cron job for let’s encrypt renewal
- Prevent duplicate cron jobs running
- Update last created post in custom post types with wp_cron()?
- Error code 499 on specific cron job
- Creating a background process that doesn’t need HTTP