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.
|
If you're new to Webtlk.com, you may want to subscribe to my RSS feed or press CTRL+D to bookmark me. You can also make a small donation using PayPal. Thanks a lot! |
Tags: GoogleApp, trick, WebTalk, Wordpress
Related Articles
Latest Articles
If you can not find what you are looking for, you might want to try and get thousands of results, specifically selected for you.
Google Advanced Search
|
Leave a Comment
Best screen resolution 1280x800 or higher.
Web Talk is best viewed in Firefox.





Comments
How to stop Windows 7 reboot loop: William, it will work even in XP samse as on Vista or Win 7 .-= Joseph´s last blog...
How to stop Windows 7 reboot loop: Frank, would this also work with Vista sp2?
How to use Wolfram Search and Google Search togheter: Read more: Web talk
How to sign up for a GoogleMail.com e-mail account: Hi I can create a googlemail.com account from UAE Thanks for your...
How to turn your articles, post and whatever you write to video: Hi William! To tell you the truth I thought about...
How to turn your articles, post and whatever you write to video: Frank, have you tried video blogging yet...
How to activate a window by hovering over it in Windows 7: I was wrong. It does work in Vista. And I hated it. If I...
How to convert Webpages (.HTML) to .PDF: The website works now. Just enter address of a web page and you will see a...