Using WordPress Cron and WP-Crontrol to make you post more

This entry is part 2 of 3 in the series Taking control of WP-Cron using WP-Crontrol

The new version of WP-Crontrol allows you to add new cron entries with code. This allows you to write code that will repeatedly be executed without actually touching any .PHP files. Below, I present a way to utilize this functionality to remind you to post something if you haven’t done so in the past two days.

PHP Cron Entry Screen

PHP Cron Entry Screen

The first requirement is to install WP-Crontrol. This will add the Manage->Crontrol admin screen. Head there and you’ll get a quick insight into what’s going on behind the scenes in the WP-Cron system. We want to add a new PHP cron entry, so click on the small link next to ‘Add Cron Entry’. Now you should have something like the screen to the right.

The code that we’re going to use for the hook is below. I won’t go deep into it. Suffice to say, it looks at the date of the most recent post. If it’s more than 2 days old, it sends out an email reminder.

    global $post;
    $recent = new WP_Query("showposts=1");
    if( $recent->have_posts() ) {
        $recent->the_post();
        if(time()-strtotime($post->post_date)>60*60*24*2)
            mail('scompt@scompt.com', 'Post reminder',
                 "Hey!  You haven't posted in a while.");
    }

The only other options to set are when to run the hook and how often. After saving the hook, it should run immediately. Depending on how good you’ve been, you’ll get an email.

Series Navigation«Add a new WordPress backup schedule with WP-CrontrolUse WP-Crontrol to keep track of Akismet»

Possibly Related Posts

1 Comment

  1. Use WP-Crontrol to keep track of Akismet « scompt.com Said,

    June 19, 2008 @ 3:57 pm

    [...] control of WP-Cron using WP-CrontrolAdd a new WordPress backup schedule with WP-CrontrolUsing WordPress Cron and WP-Crontrol to make you post moreUse WP-Crontrol to keep track of AkismetIf you’re using Akismet to tackle spam on WordPress, [...]

RSS feed for comments on this post