If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Sometimes you don't want your Wordpress blog to display the regular ads on a particular post. While some plugins can manage that, usually they mean more processing job to your server.
Custom Fields are an easy way to solve the problem.
First of all, add this code to your single.php, where you want to display your ads:
<?php if (get_post_meta($post->ID,'noadsense',true)!=1) { ?>
Your adsense code
<?php } else { ?>
Any other ad code
<?php } ?>
This code will call your Custom Field information. I used "noadsense" for a name because it's a very popular affiliate program. You can use whatever name you feel like.
Now you have to edit or create the posts you want to display your alternate ad:
At the bottom of your "write post" page, look for "Custom Fields" and add the key noadsense, with a value of 1. You only have to do this once, the next time you just select the key from the drop down menu.
Click on "Add Custom Field" and save or publish your post. It will display the alternate ad you chose. Other posts will keep showing the default ad.
You can use the code in more than one place, with different ads combinations, as long as on single.php, since Custom Fields need to grab information from your post ID.
Just remember that the code in green must be your default ad.
I think everything is quite clear, feel free to leave a comment if you have any doubts.

Leave a Reply