We use Google Adsense or any other ad servers for make money
You can use this ads on your old posts. There is also a plugin called “Who sees ads”, an advanced ad management plugin that lets you decide who will see your ads, depending on user defined conditions. But I will like to show you how you can achieve that without using plugin.
In order to monetize your blog without annoying your loyal readers with ads. What about displaying ads only when posts are older than 15 days? It is a well known fact that your regular visitors don’t click on your ads.
To achieve this, simply open your Wordpress functions.php file and paste the following code in it:
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;
}
Once done, you are now ready to call the functions in your single.php template as shown below:
<?php if(is_old_post()){ ?> INSERT AD CODE HERE <?php } ?>
That’s all, you’re done. By default, ads will be displayed on post older than 15 days. To change this value, simply edit the $days variable on line 2.
If you enjoyed this post, please share!
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.