Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a site running WordPress and the Twitter Wordpress plugin (http://community.plus.net/opensource/twitter-wordpress/)

My host does not provide access to crontab, so I am looking for a way (plugin?) to run the Twitter Wordpress update automatically on a scheduled basis. According to the plugin website, this is possible:

If users wish to have regular/automatic updates of their Twitter account tweets, then that is achievable through creating a crontab entry, or similar automation mechanism, to execute the supplied “runTwitterScript.php” file.

The question is: how can I do this without cron access?

share|improve this question
add comment

3 Answers

WP has cron-like functionality - have a look at wp_schedule_event

There's also a good little howto here: http://wpengineer.com/1908/use-wordpress-cron/

share|improve this answer
add comment

I love this plugin here (so simple) Crony Cronjob Manager

share|improve this answer
    
Martin: How you would you set this plugin up to run a .php file in the plugin directory? I have tried putting the path to the .php file under "Script to Include" but it does not work. Do I need to also fill in "Function to Run" and/or "Custom PHP to Run"? If so, with what? –  Darren Cope May 28 '11 at 16:07
    
Sorry didnt notice a reply in my inbox:.. re your question, i use the "Custom php to Run" field, a quick example is <?php global $wpdb; $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'sales' OR post_type = 'rentals' OR post_type = 'business' OR post_type = 'bandb' AND DATEDIFF(NOW(), post_date) > 365"); ?> which deletes posts after 1 year –  MartinJJ Jun 2 '11 at 17:30
add comment

Personally I think this plugin is badly coded and should be making use of the internal wp-cron features rather than relying on an external cron.

I've looked at the plugin code and the update is triggered by this function twitterScriptMain(). So what we want to do is trigger this function every so often here is the code to do that every hour:

add_action("sc_twitterscript_cron", "twitterScriptMain");
function sc_twitterscript_loaded() {
    if ( !wp_next_scheduled( 'sc_twitterscript_cron' ) ) {
        wp_schedule_event(time(), 'hourly', 'sc_twitterscript_cron');
    }
}
add_action('plugins_loaded', 'sc_twitterscript_loaded');

Add this code to your theme functions file. I haven't tested the code as I don't use this plugin. Let me know how you get on with this.

share|improve this answer
    
Thanks Brady, I will give this a shot when I'm back on this project. Hopefully in the next day or so. I will let you know how it goes! –  Darren Cope May 27 '11 at 12:57
    
Brady, does the code need to go in any particular location in the functions.php file? I pasted it in there at the start of the file and it doesn't appear to be doing anything. –  Darren Cope May 27 '11 at 15:23
    
@Darren - no it doesn't matter where it goes in the functions file. This is scheduled to run every hour to update the tweets. try leaving it for an hour first and see if anything happens. Also make sure the rest of the plugin is configured correctly. –  Brady May 27 '11 at 15:29
    
Hi Brady; It's been (well) over an hour, and still no change. The plugin works fine when I manually run it from the Admin interface. –  Darren Cope May 27 '11 at 16:38
    
One moment im going to install this on my test dev –  Brady May 27 '11 at 16:42
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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