Apr 10, 2012

Set a releven keyword for Chitika in WordPress

In Chitika, you must set your own categories / keywords that you want to show ads, not like Google Adsense to display relevant ads automatically.

For example like this, I have 2 posts, one in the Books category and one in category Movies. To display the appropriate ad posts that are in the category Books, Chitika code it like this (here I use the example code for Chitika Related Product Units):


<script type="text/javascript"><!--
ch_client = "YourUserId";
ch_type = "rpu";
ch_noprice = "1";
ch_shufflequeries = 1;
ch_width = 468;
ch_height = 90;
ch_non_contextual = 1;
ch_sid = "NamaChannelAnda";
var ch_queries = new Array( " Books " );
var ch_selected=Math.floor((Math.random()*ch_queries.length));
if ( ch_selected < ch_queries.length ) {
ch_query = ch_queries[ch_selected];
}
//--></script>
<script src="http://scripts.chitika.net/eminimalls/mm.js" type="text/javascript">
</script>


Meanwhile, to display advertisements in accordance with the existing posts in the category "Movies", just change it "Books" in the above code with the "Movies".

Well, every time we have to paste the code into corresponding category, Bother you, ain't it? so how we want to put Chitika code automatically direct fit into the category of each post?

After a few tweaking, I found out how. I'm not good in programming so if there any master programmer or who knows an easier way to do so, please do not laugh on me .. newbieee hehe .. it is also just to show Chitika ads that are relevant in the single post, rather than at home, but can also be used in the archive category.

First, add the following code in the category-template.php file contained in the folder wp-includes:


get_the_category_list_by_jim function () {
$ Categories = get_the_category ();
$ I = 0;
foreach ($ categories as $ category) {
if (0 <$ i)
$ Thelist. = ',';
$ Thelist. = '"'. $ Category-> cat_name. '"';
+ + $ I;
}
;
apply_filters return ('the_category', $ thelist);
}

the_category_by_jim function () {
get_the_category_list_by_jim echo ();
}


Please replace get_the_category_list_by_jim and the_category_by_jim : Grin2: with whatever you want, just do the same with the name of the function that already exists.

Then, in the single.php file (or archive archive.php to category) contained in the folder you use WordPress theme, add the Chitika code is in place you want its ads appear:


<script type="text/javascript"><!--
ch_client = "YourUserId";
ch_type = "rpu";
ch_noprice = "1";
ch_shufflequeries = 1;
ch_width = 468;
ch_height = 90;
ch_non_contextual = 1;
ch_sid = "NamaChannelAnda";
var ch_queries = new Array( <?php the_category_by_jim() ?> );
var ch_selected=Math.floor((Math.random()*ch_queries.length));
if ( ch_selected < ch_queries.length ) {
ch_query = ch_queries[ch_selected];
}
//--></script>
<script src="http://scripts.chitika.net/eminimalls/mm.js" type="text/javascript">
</script>


Remember! Replace the_category_by_jim the name of the function that you have set yourself (if replaced : D ). Done! Now if you look at the page source of your post, its Chitika code on line ch_queries var is in conformity with the category of the post.

How about a post included in multiple categories? Do not worry, all categories are automatically entered So for example your posts in the category Entertainment, Movies, Film and TV, then the results of its Chitika code on the line was already automated ch_queries var like this:


var ch_queries = new Array( "Entertainment", "Movies", "Film", "TV" );


Get Chitika | Premium

2 comments :

  1. Asswrwb,

    Do you a trick to make chitika ads appear even if the traffic isn't from search engine?

    ReplyDelete
  2. is it the way the algorithm works for chitika now?

    ReplyDelete

Related Posts with Thumbnails