[solved] 5 mintues to insert adsense code after few posts in wordpress

Everyone want’s to earn from his/her blog as much he/she can, but to earn from adsense you should put the ads in proper places of your blog like after 2, 5, nth post on your homepage. It will definitely increase the Adsense revenue of your website.

To achieve this you have to find and customize your index.php or home.php or front-page.php page depends upon the theme you installed like below. Find the below code..

By Default code in index.php file

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
			
<?php get_template_part( 'framework/inc/post-format/content', get_post_format() ); ?>

<?php endwhile; ?>

Replace with below code

<?php
if (have_posts()) : $count = 0; while (have_posts()) : the_post();
$count ++;
get_template_part( 'framework/inc/post-format/content', get_post_format() );
if ($count == 1 ) {
?>
[your ads code here]	
<?php
}
endwhile; ?>

you can set the condition as per you requirement like in above example it will show the Google Ads after the very first post. you can show after 2, 5 or nth post whatever you want.

If you unable to do this and still face some problem, you can hire me.

cheers…

Posted by | View Post | View Group