3

In a plugin I want to build, it deals with contests. A contest has a date on it. Does WordPress have a feature in it where it can run a piece of code every day without requiring someone to create a cron job? Basically I'm wondering if, when you build a blog with WordPress, if WordPress.org or Automattic automatically pings your site once a day or something like that. Because if that's true, I can hook that event and make it run a contest date check.

1 Answer 1

6

Check out wp_cron and the cron_schedules filter. There are lots of good tutorials out there like this one from WPTuts or this one from Viper007Bond.

2
  • Okay, so basically WordPress's built-in cron (not the one you can hook up separately through a cron job) is kind of a "hopeful cron", as in it hopes someone visits the site so that the cron runs. And it doesn't appear that sites get pinged back daily unless you set something up (like a Google Alert) to do that. Right? I mean, there's nothing in the WP code that asks Automattic or WordPress.org to ping it once a day, right?
    – Volomike
    May 8, 2012 at 2:51
  • 2
    You're right about the "hopeful" cron part, but the big advantage is that it's more "server agnostic" than a normal cron job. There are plugins, such as WP-Cron Control, that try to make up for this, though I've never used them.
    – mrwweb
    May 8, 2012 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.