Create cron job without a plugin?
Just look at the examples in the WordPress Codex for: wp_schedule_event wp_schedule_single_event
Just look at the examples in the WordPress Codex for: wp_schedule_event wp_schedule_single_event
How does one go about locking down transient API requests for multiple threading? Has anything done some benchmarking, just how much can the transient API handle for multiple concurrent requests? Under normal circumstances Transients API is essentially thin wrapper on top of Options API. The difference is that (unlike plain options) transients might make use … Read more
I just encountered this very same problem. I was trying to do wp_insert_post() from within a cron action, and the script would apparently just die during some save_post action handler. I tracked down my problem, which turned out to be a save_post handler which is used to save the POST data from a custom metabox. … Read more
You need to call add_action from outside the class, with a reference to the object. Example: $cj = new Cronjobs; add_action(‘update_properties_daily’, array(&$cj, ‘do_updates’));
Plugins such as WP Super Cache have a setting for that. It’s called “pre-load”, it allows you to pre-load pages and you can set an specific interval to regenerate cache. If you publish at least 3 or 4 times a week a good configuration could be every 4000 minutes.
To disable WordPress Cron Jobs, place this in wp-config.php: define(‘DISABLE_WP_CRON’, true); To schedule a cron job in Linux with cPanel for example… This is the command you might run: wget -q -O – http://www.your-domain.org/wp-cron.php?doing_wp_cron >/dev/null 2>&1 The end of the above command just suppresses any output. Just pick the interval of your choice for setting … Read more
This is what worked for me: require_once ‘wp-config.php’; global $wpdb; $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ); $Query= new WP_Query($args); You can use similar way to achieve what you want.
It depends. The initial page load trigger should not but performance may degrade as visitors browse your site until the Cron job is finished. Is the scheduled event you plan on using PHP or DB intensive? How often will it run? Here’s how it works The scheduled event (aka Cron job) will be initialized once … Read more
Not tested, but what if you use WC()->cart->get_cart() to retrieve the cart contents instead of the global $woocommerce object? However, I believe the problem is that cart contents require the user’s session, and accessing it via cron won’t know who the user is. You might need to start querying the database directly through $wpdb in … Read more
It depends on the plugin and the cache method you are using. For example, as far as I remember, WP Super Cache offers two different cache methods: PHP Cache HTML Cache Using the first method creates PHP cache files that still load WordPress’s functions, but do not go through the whole loading process. If this … Read more