Poiesis Web Development » admin

Author Archive for admin

WordPressIn our last post we looked at hard coding your Google Adsense code to the loop in your index page. That will display Adsense on your home page and your archive pages. In this post we’ll look at creating a short code to place adsense in your posts on the fly without having to copy and paste your Adsense code. This requires us to add a function and a short code to the functions.php page of your theme.

Don’t worry, it’s not complicated at all. Just open your functions.php file in your theme’s folder and scroll to the bottom of the file. Here we’ll add the following code:

Continue reading “Adding a short code for Adsense insertion into your post” »

Tags: , ,

WordPressThere are a number of plugins you can use to add Google Adsense to your blog. Unfortunately, most of them have very little flexibility when it comes to the positioning of the ads. But fret not; there are a few hacks you can use to hard code the Adsense code to your blog. These hacks are applied to your theme.

The obvious place to have your Adsense is on your home page. In this post, we’ll look at inserting Adsense on your hope page. This would be in the loop in the index.php page. As you can guess, it will also be applied to other pages that use the loop, namely the various archives pages.

Let’s begin:

Open the index.php file of your theme and find the line <?php if ( have_posts() ) : ?> and add the following just before this line:

<?php
    $postnum = 1;
    $showadsense1 = n1;
    $showadsense2 = n2;
    $showadsense3 = n3;
?>

Just change n1, n2, and n3 to whatever posts you want the Adsense to appear after. So if you want it to appear after the 1st, 4th and 8th posts, just change it to 1, 4 and 8 respectively. Also, if you only want one Adsense unit in the loop, discard the lines: $showadsense2 = n2; and $showadsense3 = n3;.

Continue reading “Adding Adsense code to your blog” »

Tags: , , , ,