Insert AdSense In Post

Implementation


As I’ve been told before, this tricks only applied for Single page template or any page that displaying full articles. Here’s how: This applies for wordpress blogs only


For blogger users there is no such way, the only possible way may make your account blocked, because you must change the adsense code to post it in blogger posts which is forbidden by google.

Open your Single Post Template (usually at single.php)
Find out this code inside your template:

Change the above code with this code:

”, $content);
for ($i = 0; $i
if ($i == $where) { ?>

//Your Advertisement codes

”;
}
?>

Save the template and see the result.

2nd line is a variable to determine the paragraph that you want the code to be inserted. The important thing you have to know, since index PHP is started from 0, then the value of “$where = 4;“ in the above code means the 5th paragraph ($where + 1)
To implement the Adsense ads or other advertisements, you can locate it at the 8th line. The result can be seen here:

insert adsense

For publishers or webmaster who wants some modification, the codes can be altered to make it suitable inside any site. The alternate codes to implement the AdSense (advertisements) ads are:

To place the ads at the left side, change the 7th – 9th line to:


// Your AdSense / Advertisement codes

To place the ads at the right side, change the 7th – 9th line to:


// Your AdSense / Advertisement codes

To place the ads at the center area, change the 7th – 9th line to:


// Your AdSense / Advertisement codes

To make the ads always at the most bottom paragraph, change the 2nd – 4th line to:
$content = apply_filters(’the_content’, get_the_content());
$content = explode(”

”, $content);
$where = count($content)-1;

To randomize the ads placement, change the 2nd – 4th line to:
$content = apply_filters(’the_content’, get_the_content());
$content = explode(”

”, $content);
$where = count($content)-1;
$where = rand(min, count($content)-2);

Note: min = the minimum paragraph will be used, change it! (1st paragraph = 0)

No comments: