Send a review notification email to admin when a post is 12 months old

Question

I’d like to send an automated review email to the site admin whenever a post has been published for more than 12 months.

I’ve tried using the following code but can’t seem to get it to work, or perhaps it’s that I’m not entirely sure where I would put it or how I would call it???

Any help would be greatly appreciated.

//send review email to admin
function post_review_notification() {
    $old_post = 60*60*24*365;
    $site_title = get_bloginfo( 'name' );
    $to = get_option('admin_email');
    $subject = .$site_title .'- Please review' .$post->post_title;
    $message = 'This post is over 12 months old, please update or retire '."n".'Post Title: ' .$post->post_title. "n"."Visit the post: " . get_permalink( $post->ID );
    
   if((date('U')-get_the_time('U')) > $old_post) {
        wp_mail( $to, $subject, $message );
      }
      else {
      }
}
0
Trevor Petrie 4 months 0 Answers 9 views 0

Leave an answer