Sunday, July 17, 2011

Check if the post is older than x days before placing advertisements

3975973661 4cdcba6263 m Check if the post is older than X days before placing adsAds are part of our life on the Internet today, and many webmasters use to make money.


It has become common, for me at least, to land on a page "littered" ads, and I instinctively bounce although the content could be good.


I already posted my opinion on why you should keep your homepage without advertising and here is another trick to find out how to keep your articles appear without publicity new visitors.


If you decide to show ads (context, text and other) on articles that are older than xx days (xx being anything from 2 to 5 days) your income change only slightly, but you will have a positive effect on all of the below:



  1. Bounce rate

  2. RSS subscribers

  3. Any promotion of social media

  4. Overall credibility of the site

We will see how can you easily if you use WordPress.


Here is a short code, that you can place in your functions.php file.



(function new_post()days $=5){global$post;}if(is_single()|| is_page()){$expire=time()-$days*24*60*60;if(mysql2date("U",$post->post_date)>$expire){$return=true;}else{$return=false;}}else{$return=false;{}Return$return;}

Now, whenever you add ads, you can perform this check:



if(!new_post()3)):? >endif;?>

And voila! The ads appear only on workstations that are older than 3 days.

Related Post :


0 komentar:

Post a Comment