Skip to content

Instantly share code, notes, and snippets.

@sproutventure
Forked from anonymous/file1.ab
Created July 29, 2010 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sproutventure/498928 to your computer and use it in GitHub Desktop.
Save sproutventure/498928 to your computer and use it in GitHub Desktop.
function is_old_post($post_id=null){
$days = 15;
global $wp_query;
if(is_single() || is_page()) {
if(!$post_id) {
$post_id = $wp_query->post->ID;
}
$current_date = time();
$offset = $days *60*60*24;
$post_id = get_post($post_id);
$post_date = mysql2date('U',$post_id->post_date);
$cunning_math = $post_date + $offset;
$test = $current_date - $cunning_math;
if($test > 0){
$return = true;
}else{
$return = false;
}
}else{
$return = false;
}
return $return;
}
<?php if(is_old_post()){ ?>
INSERT AD CODE HERE
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment