WordPress Cron Schedule the if and else statement

wp_cron is a PHP level system and so also only runs on page load. It does not run on clock time so you’d still need to reload the page to get the loop to run.

Second, to get this working with wp_cron you’d need to pull all of your posts with _limited_dates_to set and loop through them. You’d need to do that every time the wp_cron job runs. That is likely to be a lot of server load as I doubt your expiration times fall into neat blocks that allow you to run a wp_cron job every few hours.

As is, you can check one post at a time as needed. That, I would argue, is the better way of doing this than using wp_cron.

Even if you have server access that allows you to set up a real system cron job you still have the same problem with needing to Loop through all posts with _limited_dates_to set.

Unless you have a very convincing reason that this needs to use wp_cron or cron, and it works as is, I’d say “leave it alone”. I don’t see the benefits and I do see potential drawbacks.

Leave a Comment