here is a 3-step tutorial which will guide you .. it's very simple here's an example - have a look
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
| <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php the_date( '' , '<h2>' , '</h2>' ); ?> <div <?php post_class() ?> id= "post-<?php the_ID(); ?>" > <h3 class = "storytitle" ><a href= "<?php the_permalink() ?>" rel= "bookmark" ><?php the_title(); ?></a></h3> <div class = "meta" ><?php _e( "Filed under:" ); ?> <?php the_category( ',' ) ?> — <?php the_tags(__( 'Tags: ' ), ', ' , ' — ' ); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__( 'Edit This' )); ?></div> <div class = "storycontent" > <?php the_content(__( '(more...)' )); ?> </div> </div> <?php comments_template(); // Get wp-comments.php template ?> <?php endwhile ; else : ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif ; ?> |
2. Find the following line,
1
| <?php if (have_posts()) : while (have_posts()) : the_post(); ?> |
then insert the following code above it.
1
| <?php $count = 1; ?> |
3. Find the following line,
1
| <?php comments_template(); // Get wp-comments.php template ?> |
add the following codes above it.
1
2
3
| <?php if ( $count == 1) : ?> YOUR GOOGLE ADSENSE CODES HERE <?php endif ; $count ++; ?> |
4. You can display any ads you want just simply replace “YOUR GOOGLE ADSENSE CODES HERE”. $count == 1 means your Adsense ads will be displayed between the first & second post on homepage. So if you want to display the ads on third post, you should edit the number to 3. That’s it!