• Hi,

    I want to know if wp_schedule_event (hourly execution cron) should be mandatory in functions.php or even can be in any plugin.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It can be in a plugin. In fact, F J Kaiser added a comment to the Codex page a couple weeks ago (with no explanation) implying using it in a theme could be problematic.

    This probably because a recurring event should be scheduled only once, such as during plugin activation. Doing so from functions.php will result in a redundant scheduled event being added for every WP page requested!

    Note that you could put the scheduler inside a conditional that checks for the existence of a schedule already with wp_next_scheduled(). In such a case, scheduling from functions.php should work OK.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_schedule_event’ is closed to new replies.