I have to run a PHP script through real cron (WP cron being too unreliable). Within that script, I need $wpdb to insert data into WordPress table. But of course $wpdb will not be available as WordPress would not be initialized. Right? So, my question is how to 'include' WordPress/initialize WordPress environment to do such tasks? How about require_once("wp-load.php")?
Tell me more
×
WordPress Answers is a question and answer site for
WordPress developers and administrators. It's 100% free, no registration required.
|
You can use real cron to trigger WP cron - by fetching That will take care of environment and everything. |
|||||||
|
|
If you want to trigger any script via cron you can also skip wp-cron (limited functionality anyway) and cron the script directly. The script have to load the wordpress environment itself if it wants to use wordpress functionality. A solution to this can be found here : Initialize WordPress environment to use in command line script |
|||
|
|