If you are a blogger you know only too well how important to put advertising on your bog is in order to pay your monthly and yearly fees to manage your internet activity. In fact, you have to pay the web hosting provider, ask for help to programmers just in case something gets screwed, pay a designer to get a better theme, pay Adword to let other people know about you and what you are doing etc. If you start blogging seriously and you are not into programming, at a certain point you have to pay to get help. Blogging is a continue work in progress. Usually readers don’t see a lot about this feverish activity, apart when a new article comes out, but I assure that behind the scenes there is a lot of work and posting articles is just the tip of the iceberg. Blogging is an extreme dynamic activity made of hundreds of big and small daily adjustments. OK, I apologize for this little off-topic… There are a lot of ways to get money from your blog, but the most used one is, without any doubt, Google Adsense. There are dozens of plugins letting you put its code among your pages or promising you to fine tune it, but what if you don’t manage to find the right plugin reproducing the behaviour you are looking for? A solution is to know a little bit about php programming, make a custom piece of code and put it into your blog’s theme. Let’s make an example. In the past weeks I have have been looking for a plugin which lets me put Adsense in the main page of my blog ( by the way, I use Wordpress) at specific intervals, let’s say one advertising every 3 posts. Well, believe it or not but I didn’t manage to find it at all. Lucky for me and you all, there are a lot of good guys out there willing to help you for the sake of it. This is the trick I managed to get from a good willed guy:
- Get access to your blog thorugh your FTP software.
- Go to /public_html/wp-content/themes/yourTheme.
- Open Index.php (which corresponds to your blog’s homepage loop).
- Add this piece of code right above <?php if (have_posts()) : ?>: <?php $counter = 2; ?>
- Add this other piece of code containing your Adsense right before <?php endwhile; ?>: <?php if(++$counter % 3 == 0) { Echo ‘Your Google Adsense code here’; } ?>
The behaviour you should expect from this code is that it will put a Google ads at the bottom of the first post of your blog’s homepage. It will also put a Google ads every three posts, following thus this frequency: 3,6,9,12 etc. If you want your Google ads to follow a different frequency, just change the figures in the code.
Tags: GoogleApp, trick, WebTalk, Wordpress
If you're new to Webtlk.com and like what you read, you may want to subscribe to my RSS feed or press CTRL+D to bookmark me. Thanks for visiting!
Leave a Comment
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.


Comments
Block an entire country by stopping its IP addresses with BlockaCountry: Thanks, Webtalk. I have added that code to...
Block an entire country by stopping its IP addresses with BlockaCountry: Hey John, thanks for your link. It seems to...
Block an entire country by stopping its IP addresses with BlockaCountry: How do you know that Google crawls them all?...
Block an entire country by stopping its IP addresses with BlockaCountry: Hi webtalk I need help. I think I have a...
Block an entire country by stopping its IP addresses with BlockaCountry: You can check also: http://shoxt.com/block.php -...
Enable more than 4 GB of RAM in 32 bit Windows Vista : haha nvm I didn’t have sp1 that fixed it
Firefox Minefield: Firefox Minefield- As a matter of fact, the Mozilla team is developing its next-gen...