Tag Info

Hot answers tagged

10

My favorite plugin for that is Core Control which has very nice module for display of what is going in the cron - which events are set up, when are they next firing, etc. On getting your hands dirty level see _get_cron_array(), which returns internal stored data for cron events (top level of keys are timestamps).


10

The answer is apparently YES, I should worry. After some research, I've found that the warning seems to be related to misconfigurations on the server that WordPress is hosted on (ie. a problem with my server, not WordPress). Common misconfigurations: Server doesn't have DNS, and so it can't figure out who "example.com" is, even though it is itself. Server ...


10

I know I'm three months late, but the function you want here is get_date_from_gmt(). The function accepts a GMT/UTC date in Y-m-d H:i:s format as the first parameter, and your desired date format as the second parameter. It'll convert your date to the local timezone as set on the Settings screen. Example usage: echo get_date_from_gmt( date( 'Y-m-d H:i:s', ...


8

After some testing indeed, both WP Super Cache and W3 Total Cache do not release the buffer (or prevent the buffer from being released). Turning off "output delay" is simple and depends on the caching plugin involved. WP Super Cache: wp_cache_disable(); ob_end_flush(); // or ob_end_clean(); This should be added after including wp-load.php, this stops ...


7

Thanks to Rarst this makes a hell of a lot more sense now. So I've updated this post to elaborate the differences Rarst mentioned and upvoted his for shedding light on this ; ) Basically wp_schedule_single_event passes the arguments to your function through the variable args as shown in the codex. This variable "args" must be an array because each value in ...


7

I think you have mismatch in how you pass arguments and how you expect it to work. You pass array of arguments to schedule and expect your hooked function to receive identical array of arguments. This is not the case. Cron events are processed by do_action_ref_array(), which in turn passes arguments via call_user_func_array(). So your hooked function does ...


7

Neither. register_activation_hook( __FILE__, 'trigger_me' ); function trigger_me() { if ( !wp_next_scheduled( 'my_plugin_cron' ) ) { wp_schedule_event(time(), 'hourly', 'my_plugin_cron'); } } Why parse code on every request when you don't need to?


6

Firstly, define your custom cron job schedules. add_filter('cron_schedules', array($this, 'cron_schedules')); public function cron_schedules($schedules){ $prefix = 'cron_';// Avoid conflict with other crons. Example Reference: cron_30_mins $schedule_options = array( '30_mins' => array( 'display' => '30 Minutes', ...


6

It's a sign that you have ALTERNATE_WP_CRON defined in your wp-config.php In order to do some background processing (like publishing scheduled posts), WordPress redirects you to the URL with ?doing_wp_cron appended.


5

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.


5

WordPress lets you add custom cron schedules, which is normally what you'd want to do in this situation, in conjunction with wp_schedule_event(). But, they work based on intervals rather than specific dates/times. For instance, add_filter( 'cron_schedules', 'addCustomCronIntervals' ); function addCustomCronIntervals( $schedules ) { $schedules[ ...


5

Edit: wp_next_scheduled() returns the timestamp of the next scheduled job of a specified wp-cron job-arguments pair. Please note that this differs slightly in functionality to the answer below, in that you have to provide the arguments passed to cron job's callback (if it has any). The original answer would provide the time of the next specified job ...


5

This is what normal query run by wp_get_associated_nav_menu_items() looks like: SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id ) WHERE 1 = 1 AND wp_posts.post_type = 'nav_menu_item' AND (( wp_posts.post_status <> 'trash' AND wp_posts.post_status ...


4

The Problem: When wp-cron.php is called, it includes only: require_once( dirname( __FILE__ ) . '/wp-load.php' ); so the problem you are facing is that wpmu_delete_blog() is undefined when you call it from your remove_blogs_daily() function. Possible Solution: You therefore need to add this line: require_once( ABSPATH . 'wp-admin/includes/admin.php' ...


4

Why don't you just create a cron job, make a database dump and look where the info about the cron job is kept? That's what I did. As suspected, WordPress 3.5.1 keeps its cron jobs in the {wp}_options table under the name 'cron'. SELECT * FROM `wp_options` WHERE `option_name` LIKE '%cron%' Or through functions.php: $cron_jobs = get_option( 'cron' ); ...


4

wp_cron is used to schedule tasks such as deleting old posts from trash, deleting old spam comments, and checking for plugin/theme updates.


4

Whenever you do get_posts or WP_Query or anything like that, it's important to remember that the code is actually getting all of the Posts at once, and loading them from the database into memory. If you run out of memory, then your process will simply die with an error. Attempting to get very large numbers of posts at once will cause this quite often. Turn ...


4

As you've noted, cron jobs are only fired when someone visits your website. WordPress checks if they are any events that have been scheduled before 'now' that have not yet occurred - and runs them. Importantly with events that are recur according to a regularly pattern (say hourly) - their occurrence is relative not absolute. That is, once your event ...


4

Yes, the event will trigger when the wp-cron process gets run. If something is preventing wp-cron from running, then it won't trigger at all. If you're having it not work, then something about your server configuration is preventing it from working. For these cases, you can generally work around them by adding this define to your wp-config file: ...


4

Due to your server configuration, you may need to use the alternate cron method, which uses redirect rather than http loopback. Try adding the following to your wp-config.php file: // Alternate cron method define( 'ALTERNATE_WP_CRON', true );


4

It looks for me that you are adding this event only when there is no such event 'send_email_alerts_hook' scheduled yet. Try something like this and let me know if it workded. function shedule_email_alerts() { if ( !wp_next_scheduled( 'send_email_alerts_hook' ) ) { wp_schedule_event(time(), 'daily', 'send_email_alerts_hook'); } else { ...


4

This is only a partial answer. You can use Cron View to see what crons are still active on your blog. If you find some crons that shouldn't be there then maybe my answer here will help you remove that cron: Cron jobs for deactivated plugins


4

Disable any plugins you may have that do whole-page caching. WP-Super-Cache, W3 Total Cache, etc. WordPress does not "delay output". But whole page caching plugins usually do. This is because they are trying to get that output and save it somewhere, for later usage in serving the page. Thus, the page output is delayed until the end, where the plugin can ...


3

Although both of your options (that is, using transients or using a cron job) are viable, I'm a fan of using transients unless the dataset is exceptionally large or if there is some need to automate the process. Without seeing much of your current code, it's difficult to give a working example. Nonetheless, if you end up going the route of transients, I'd ...


3

You can do this via wp_cron by using the following, function more_reccurences() { return array( 'sixhourly' => array('interval' => 21600, 'display' => 'Every 6 hours'), ); } add_filter('cron_schedules', 'more_reccurences'); then find the function that does the autopost and call it by if ( !wp_next_scheduled('autopost_function') ) { ...


3

Where are you putting the wp_schedule_event() code? My guess is, you have it somewhere that's causing it to run on every page load, causing the action to be scheduled multiple times (like maybe you just dropped it in your functions.php?). You only need to schedule the action once. The easiest way is to do it on activation of your plugin. Try something like: ...


3

First can you please confirm that you don't have any caching plugins enabled? Caching plugins can interfere with cron jobs because your visitors are not served a live page but a cached version of your page. If you have a caching plugin enabled, you can choose one of your pages, add an exclussion to your caching plugin's settings for that page so that it is ...


3

Basically every page load looks to see if there is anything scheduled to run, so by that logic the cron is checked and can possibly run on every page load. I can only presume you want to schedule something to run every so often. If that's the case you need to look at wp_schedule_event() Below is the code to get some code to run ever hour: ...


3

After this remark from the OP: To be clearer, I have scheduled posts in the future, and I want the cache to clear when the are published via the wp-cron trigger. There might be a better way? I do not know if the W3 Total Cache plug-in not automatically flushes the cache when posts are published. I believed it did. If it does not - then in this intance ...


3

The cron event needs to be registered on the plugin activation hook like so: register_activation_hook( __FILE__, 'activate_cron' ); function activate_cron() { wp_schedule_event( current_time( 'timestamp' ), 'hourly', 'the_function_to_run' ); } The the_function_to_run defined in the wp_schedule_event needs to be your function that you want to run at ...



Only top voted, non community-wiki answers of a minimum length are eligible