Do you think Kontera ads look “junky?” Tricia did. Bloggers have used them to make money, but the links can be distracting: let’s face it, contextual doesn’t necessarily equal meaningful!
Depending on the blog content, the context links can be really aggravating to blog visitors! If you don’t control them properly, you could lose regular readers or never attract them in the first place!
I thought about this problem and decided I would prefer to keep the Kontera ads out of the most recent blog articles, but allow them show up in archives. It’s a compromise that lets my regular subscribers get a less ad intensive experience, but shows ad links to visitors who wander to the blog by way of search engines.
So, I wrote some PHP code that lets me run Kontera ads, but:
- Keeps ads out of all posts that are less than 20 days old.
- Keeps ads out of all sponsored posts that are less than 60 days old. (At my knitting blog, sponsored ads are in “category 60″.)
- Doesn’t slow down to load the Kontera Javascript when I’m not showing any ads at all!
If you visit the main page of my knitting blog you’ll see no Kontera ads. If you visit an older article in the archives you may see ads, (though not many because knitting doesn’t generate a huge number of words that get linked. If you want to see mega-Kontera linkage visit my diet blog!)
You can change dates and category numbers to match your needs and the TOS of any programs in which you participate.
So, now for the code!
This is the code you want to wrap around the part of your template that actually creates the content of the post. If your blog template in sell organized, you’ll find it in a file called “post.php” called from your main template file. The code to add is shown in red font:
Code:
<?php
$earlyAd = time() - 86400*60; // wait 60 days before slapping extra ads in sponsored.
$earlyPost = time() - 86400*20; // wait 20 days before slapping ads in other blogs.
if (mysql2date('U', $post->post_date) < $earlyAd) {$oldAd=1;} else {$oldAd=0;}
if (mysql2date('U', $post->post_date) < $earlyPost) {$oldPost=1;} else {$oldPost=0;}
// When sponsored_supress_Kontera==1, the page won't even waste time loading the Kontera script.
if (is_home()) {$GLOBALS['sponsored_supress_Kontera']=1; }
// edit the value of '60' to match the category you are checking to remove Kontera adds from sponsored ads.
if (in_category(60)&& $oldAd==0) {
$filter='"KonaFilter"';
if ($single) {$GLOBALS['sponsored_supress_Kontera']=1;
}
}
else if( in_category(60)) {$filter='"Konabody"'; }
else if($oldPost==0) {$filter='"KonaFilter"';
if ($single) {$GLOBALS['sponsored_supress_Kontera']=1;}
}
else {$filter='"Konabody"';}
?>
<?php
// insert the span tag into post:
echo('<span name='.$filter.'>');
?>
<!-- actual post post.php -->
STUFF EVERYTHING THAT SHOWS YOUR INDIVIDUAL POST IN HERE.
<!-- end actual post.php -->
<!-- close the span tags-->
<?php echo(<'/span>'); ?>
This is a footer code to speed loading in cases where the span tags are preventing Kontera ads from appearing on the full page:
<php
global $sponsored_supress_Kontera;
if($sponsored_supress_Kontera==1){
echo('
No Kontera ads.
');}
else{echo('
Kontera ads show.
');
?>
<!-- Kontera ContentLink™ -->
Stuff the javascript for the Kontera ads in here.
<!-- Kontera ContentLink™ -->
}
?>
Bonus tip: While searching for blogs that complained about not being able to control Kontera ads, I found this trick at John Chow’s blog: to avoid Kontera ads in the headings inside <h1>, <h2>, and <h3> tags or bold text inside <b>, and <strong> tags you can add this line to your contera javascript:
var dc_isBoldActive= ‘no’ ;
So, you might as well do modify the Kontera ad while you are adding the extra PHP code!
Do all of three things, and you can run Kontera where you like, and avoid a “junky” look!
Update:
I wrote the Kontera Control plugin to do this all for you. Now you can use pulldown menus instead of coding.
Hey, great idea. I never thought of using Kontera for older posts. I really dislike Kontera, but this is actually a pretty good compromise. I’ve never heard of anybody using it this way. Great idea. =]
I just signed up for Kontera and Iam extremely new to all this. I am not sure where to add the code to it. Your code sounds awesome I think I am going to use it. If you could just point me in the direction on where to add it in my blog I would greatly appreciate it.
Thanks