I have just added adds from Chitika. They can do targeted ads just like Google AdSense, but in the Google AdSense contract you are forbidden to use that with another ad company if they use targeted ads. But there’s a way of manually add the stuff that’s supposed to show in the ads from Chitika. But that involves editing the index.php and then add that search word in the javascript variable called ch_query. But wouldn’t it be great if you could use the Custom Fields that’s already in WordPress? Well you can. And here’s how I did it. When writing your blog posting, just add a tag called “ad” in the Custom fields, and then put the search word you want, for example “ipod”. I’ve put the code so that WordPress uses the the codes when displaying a single post. So if you write a posting about photography, you can add an “ad” tag with “canon eos” or similar, and be certain only relevant adds be shown. If there’s no custom field with an “ad” entry, it just displays a Google AdSense ad instead.
The code ain’t pretty, but it does the job.
You need to open your index.php found in /wp-content/themes/yourtheme and look for:
if ($single && (empty($post->password) ||
$HTTP_COOKIE_VARS['wp-postpass_'.$cookiehash] == $post->post_password)) {
And add the following code (after editing the outlined parts of the code) after that. Then the targeted ad will only show up when someone clicks on a specific posting.
<?php
$adkey = get_post_meta($post->ID, "ad", FALSE);
if (!$adkey) {
/* No ad keyword, so display Google ads. */
/* ADD GOOGLE OR OTHER CONTENT HERE IF NO DIRECT AD TAG */
?>
<?php
}
else {
/* Now lets add the Chitika code here. */
/* All Custom Fields with tag 'ad' will be used */
?>
<script type="text/javascript"><!--
ch_client = "Your client id here";
ch_width = 468;
ch_height = 60;
ch_nosearch = 1; // Remove search tab to comply with Google Ads
<?php
/* Now take all custom fields*/
srand(time());
$adrnd = rand(0,count($adkey) - 1);
print("var ch_query = '$adkey[$adrnd]';");
?>
//--></script>
<script src="http://scripts.chitika.net/eminimalls/mm.js" type="text/javascript">
</script>
<?php
}

Here I have added three different ads. The ads will be randomly selected automatically.
Now try to load the posting in question.
You should now have a more flexible ad system, and it’s easy to update as well.
12 responses so far ↓
1 Ariane // Oct 12, 2005 at 23:22
One suggestion : when posting code, use for example http://priyadi.net/archives/2005/09/27/wordpress-plugin-code-autoescape/ Otherwise it’s just impossible to cut&paste your code with all these curly quotes and stuff
2 Jacken // Oct 12, 2005 at 23:39
Thanks Ariane! That fixed the problem.
3 Roy Schestowitz // Oct 13, 2005 at 4:35
That’s very interesting (I think I’ll trackback this entry soon). I only wonder if the additional work (specifying ad terms) is worth that little investment. AdSense is about ‘autonomousity’.
4 Ariane // Oct 13, 2005 at 7:57
Roy : it’s not adsense, it’s chitika. And to use Chitika along with Adsense, you have to make chitika ads non contextual, i.e. not let it pick a keyword from your page content. Therefore you have to feed it with keywords yourself. For more info on Chitika ads and how to hack them, refer to my guide : Chitika tips, tricks and hacking guide
5 Hiddenson // Oct 16, 2005 at 2:44
Excellent! I had to tinker the code a bit a bit to suit my needs, but nothing extreme. Thank you for sharing!
6 Richard Hendrix // Jan 30, 2006 at 4:10
Jacken,
I recently signed up for Chitika and was looking for something just like this! Thanks for providing the code, works and looks great on my site. I love the ability to customize the product for each post.
7 giloosh // Feb 16, 2006 at 4:27
im using adsence on my website http://www.pixelmerge.com but im not getting hits. why doesnt anyone visit?
8 zach shine // May 26, 2006 at 8:58
DataFeedFile.com has a Chitika alternative…
I found this site because I was kind of po when I received a rejected email from Chitika… so I went searching for alternatives.
Chitika turned me down due to not enough traffic on my blog. Fortunately I found a similar service based on a much more fair and open market. DataFeedFile.com is a similar service with much more options and banner sizes to choose from.
What I like about DataFeedFile.com is they allow you to choose what merchant to display products for. DataFeedFile.com seems to be a colaboration of hundreds of merchants from the affiliate industry. Check them out yourself, http://www.DataFeedFile.com.
Zach Zach
9 Ferienhaus mieten // Jun 24, 2006 at 20:21
nice plugin, thanks for work, more plugins for wordpress here : Word press and here P-Lugins
and custom themes here: Wordpress themes download
10 The Chitika Blog » Blog Archive » Using Custom Fields in WordPress to set your eMiniMalls queries // Nov 7, 2007 at 21:13
[...] Jacken describes in detail how you can use WordPress’ Custom Fields to easily set your own quieries: But wouldn’t it be great if you could use the Custom Fields that’s already in WordPress? Well you can. And here’s how I did it. When writing your blog posting, just add a tag called “ad” in the Custom fields, and then put the search word you want, for example “ipod”. I’ve put the code so that WordPress uses the the codes when displaying a single post. [...]
11 Blog Title Keywords Can Target Chitika eMiniMalls // Apr 13, 2008 at 5:52
[...] only to target Chitika ads, but also for better search engine optimization too. You can also add targeted ads from Chitika in WordPress and use this Wordpress plugin to add eMiniMalls in blog [...]
12 Chitika eMiniMalls Tutorial | Thenett.net // Apr 25, 2008 at 23:26
[...] Plugin - This plug in allows you to add eMiniMalls to your posts in Word Press WordPress Plugin - This plug in uses the custom fields features of WP to insert eMiniMalls WordPress Plug in - This [...]
You must log in to post a comment.