You’ll need to set up a cron job that checks once a day to see if the latest post is more than seven days old.
So, some where in a plugin file. Schedule a new event. Then hook into that event. Grab the post date, turn it into a unix time stamp, and compare that with the current time.
<?php
register_activation_hook( __FILE__, 'wpse29671_activation' );
function wpse29671_activation()
{
wp_schedule_event( time(), 'daily', 'wpse29671_cron' );
}
add_action( 'wpse29671_cron', 'wpse29671_maybe_send_email' );
function wpse29671_maybe_send_email()
{
// get the latest post
$posts = get_posts( array( 'numberposts' => 1 ) );
if( ! $posts ) return;
// Latest posts date as a unix timestamp
$latest = strtotime( $posts[0]->post_date );
// how long has it been?
$diff = ( time() - $latest ) / ( 60 * 60 * 24 );
// if it has been more than 7 days, send the email
if( $diff >= 7 )
{
wp_mail( '[email protected]', 'Better Write a Post!', 'Hey, you should go write a blog post or something' );
}
}
As a plugin: https://gist.github.com/1246814
Alternatively, you could use DateTime objects to do the time comparison or just use this plugin (but it’s way more fun to figure it out yourself, just sayin’).