We can do this in two ways. We can either edit our theme and insert the ad code to show the ad or we can use a wordpress plugin called Whydowork Adsense to do this automatically. Let’s know both tricks step by step.
Edit Theme to show Ads on WordPress Homepage Only
- Login to your WordPress dashboard
- Navigate to Appearance >> Editor >> Index.php
- Choose the location where you want to display the ad and paste the following code there
- Replace the line YOUR ADVERTISEMENT HERE with your ad code.
- Save the changes and you are done.
- Download Whydowork Adsense wordpress plugin.
- After installation, activate it from Plugins control panel.
- Navigate to Settings >> Whydowork Adsense
- You can find various options there. You can add up to 10 advertisement codes and customize it to show on different locations of your wordpress blog.
- Paste your ad code into Ad Code#1 and save it.
- Scroll down to Front Page (categories, archive) and select Ad Code#1 there.
- Manage your ad alignment and select the post nos where you want the ad to get displayed.
- Save the settings and you are Done.
<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?> YOUR ADVERTISEMENT CODE HERE <?php } ?>This trick was written by John P on his blog. Show Ads on WordPress Homepage Only using Plugin If you are not comfortable in editing theme files, you can use a wordpress plugin to do this for you. Whydowork Adsense is one of the best adsense plugins I’ve ever used. This gives you the freedom to show your ads on either post pages or homepages or both. It also allows you to align your ad to fit better with your theme. Let’s know how to use it.
That’s it. Now you can show ads on wordpress blog’s homepage only.