$ add adsense under each wordpress post by hand code $

October 12th, 2008 No comments

Sometimes I dont like to use plugin to add adsense in the blog, so I tried to add it by hand code, following is an example for add adsense under each post:

Go to the file of single.php in the theme fold, read and find the code for displaying the content, the <div class=”storycontent”> should be the code to display the content, and the <div class=”meta”> should be the code to show the post meta, so just add the script under the the post meta, I use the <hr> to isolate adsense for clearance.

<div class=”storycontent”>
<?php the_content(__(‘(more…)’)); ?>
</div><!– end storycontent –>

<div class=”meta”>

Written by <?php the_author() ?><?php _e(” in:”); ?> <?php the_category(‘,’) ?> | <?php the_tags(__(‘Tags: ‘), ‘, ‘, ‘ ‘); ?><?php edit_post_link(__(‘Edit This’)); ?>
<?php wp_link_pages(); ?><br />

</div><!– end meta –>

<hr>
******paste google adsense script here*************
<hr>

Related Blogs

$ Disable WordPress Auto-Saving and Revisions $

October 10th, 2008 No comments

Disable WordPress Auto-Saving
Open the WordPress Config File:

/wp-config.php

And add following code after the first set of functions :

define( ‘AUTOSAVE_INTERVAL’, 600 );

By Default this value is set to 60 (seconds), 600 equals 1 Hour,you can go higher, but i figure 1 hour is good for me.

Disable WordPress Revisions
Open the WordPress Config File:

/wp-config.php

And and following code after the first set of functions:

define( ‘WP_POST_REVISIONS’, 0 );

By Default this value is On (1), turn it off by setting it to Off (0) ( Zero ).

Related Blogs

Categories: wordpress Tags:

The page for google adsense search result

October 9th, 2008 No comments

Following is a quite simple html page I made for google adsense search result:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”UTF-8″>
<head>
</head>
<body>

<div align = “center”>

****google adsense search result code*****

</div>

</body>
</html>

I dont know what is the meaning of the first 2 lines:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” lang=”UTF-8″>

Categories: google adsense Tags:

Close all other browser in watir

October 8th, 2008 No comments

I used to close some browsers by following code:

puts “to close a certain previous browser”
Watir::IE.attach(:title, /google/).close
puts “to close a certain previous browser”
Watir::IE.attach(:title, /Internet/).close
puts “to close a certain previous browser”
Watir::IE.attach(:title, /Internet/).close

but when 2 or more watir programs run together, they stalled there. I don’t know the reason, so I tried the following code which worked ok:

sleep 1
puts “to close all the other browsers”
ie77.close_others
sleep 1
puts “to close current browser”
ie77.close

Categories: watir Tags:

if statement with multiple conditions in ruby

October 7th, 2008 No comments

It is difficult to find the examples demonstrating how to combine two conditions in the if statement of ruby, I tried and found following code is ok:

tmp = rand(10)

if ((tmp > 5) && (ie77.text.include? ‘fine’))
puts “fine”

else

sleep 7
end

Categories: ruby Tags:

Append text to text_field at watir

October 5th, 2008 1 comment

At watir we can submit texts to forms by such a code like : ie.text_field.set(), we could also append texts by the code such as ie.text_field.append(), following is an example:

require ‘watir’
include Watir

# Initialize the text to be submitted to a bbs
conts = []
File.open(‘goodword.txt’) do |f|
f.each_line{|l| conts << l}
end
#Initialize the advertising text to be appended
advs = []
File.open(‘adv.txt’) do |f|
f.each_line{|l| advs << l}
end
———
ie22.text_field(:name, ‘co’).set(conts[rand(conts.size)])
ie22.text_field(:name, ‘co’).append(“\n”)
ie22.text_field(:name, ‘co’).append(“\n”)
ie22.text_field(:name, ‘co’).append(“\n”)
ie22.text_field(:name, ‘co’).append(“\n”)
ie22.text_field(:name, ‘co’).append(advs[rand(advs.size)])

—–

“\n”     means change to a new line.

Categories: watir Tags: