Tips to add Google Adsense to WordPress

| December 15, 2011 | Comments (1)

Today, I will share with you some useful tips to add Google Adsense to WordPress. With these tips, you can add Google Adsense to WordPress at any where you want. Just follow these tips.

1. If you want to place Google Adsense at the top of the whole page, open your theme header.php file and place your Adsense code right after the <body> tag.

google adsense wordpress tips Tips to add Google Adsense to WordPress

2. If you want the ad at the bottom of your posts, open your theme file index.php and place your Adsense code before the lineĀ <?php get_sidebar(); ?>

google adsense wordpress tips 1 Tips to add Google Adsense to WordPress

3. If you wanted the ad to only appear under the first post and nowhere else, open your theme index.php file and find these lines:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

Paste the following codes above those lines.

<?php
$postnum = 1;
$showadsense1 = 1;
?>

google adsense wordpress tips 2 Tips to add Google Adsense to WordPress

Then scroll down to this part:

<?php wpe_excerpt(‘wpe_excerptlength_index’, ”); ?>

<a class=”readmore” href=”<?php the_permalink() ?>”>Continue</a>

</div>

</div>

Paste these codes below.

<?php if ($postnum == $showadsense1) {
echo ‘
Place Google Adsense code here
‘;
} ?>

<?php $postnum++; ?>

google adsense wordpress tips 3 Tips to add Google Adsense to WordPress

Now you can put the Google Adsense ads where you want.

Tags: ,

Category: WordPress, WordPress tips

Comments are DO FOLLOW

Comments (1)

Trackback URL | Comments RSS Feed

  1. Mr.Ross says:

    Thank you for posting this.

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.