Skip to main content
Tweeted twitter.com/#!/StackWordPress/status/160821222286954496
added 430 characters in body
Source Link
Stephen Harris
  • 32.6k
  • 6
  • 84
  • 118

I have several cron jobs all hooked to the same hook, but each with a different argument (a post ID). It appears wp_clear_scheduled_hook only clears job which match the argument passed with it (or jobs without any arguments, if no argument is provided).

Is there a way to delete all the cron jobs associated with a hook, regardless of the argument that job has? (Without doing so 'manually' by looping through the IDs).


Seems an answer was deleted! To clarify what I would like to achieve: each post has an expiration date - and I would like to delete the post after this date.

(An alternative option is to have one cron job - repeating every 24 hours that deletes any expired posts).

However, I decided to create a one-off job for each post - but it seems you can't delete all the jobs at once without cycling through them.

I have several cron jobs all hooked to the same hook, but each with a different argument (a post ID). It appears wp_clear_scheduled_hook only clears job which match the argument passed with it (or jobs without any arguments, if no argument is provided).

Is there a way to delete all the cron jobs associated with a hook, regardless of the argument that job has? (Without doing so 'manually' by looping through the IDs).

I have several cron jobs all hooked to the same hook, but each with a different argument (a post ID). It appears wp_clear_scheduled_hook only clears job which match the argument passed with it (or jobs without any arguments, if no argument is provided).

Is there a way to delete all the cron jobs associated with a hook, regardless of the argument that job has? (Without doing so 'manually' by looping through the IDs).


Seems an answer was deleted! To clarify what I would like to achieve: each post has an expiration date - and I would like to delete the post after this date.

(An alternative option is to have one cron job - repeating every 24 hours that deletes any expired posts).

However, I decided to create a one-off job for each post - but it seems you can't delete all the jobs at once without cycling through them.

Source Link
Stephen Harris
  • 32.6k
  • 6
  • 84
  • 118

Delete all scheduled events with a particular hook

I have several cron jobs all hooked to the same hook, but each with a different argument (a post ID). It appears wp_clear_scheduled_hook only clears job which match the argument passed with it (or jobs without any arguments, if no argument is provided).

Is there a way to delete all the cron jobs associated with a hook, regardless of the argument that job has? (Without doing so 'manually' by looping through the IDs).