Title: Placing code in index.php need help
Last modified: August 18, 2016

---

# Placing code in index.php need help

 *  Resolved [xinfo](https://wordpress.org/support/users/xinfo/)
 * (@xinfo)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/)
 * Hi
 * I am trying to place the add in between the post in the index page well i found
   in the codex to instruction to find the
 * <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
 * But i am not able to find it i am using default theme

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450438)
 * That’s the Loop for earlier versions.
    Look in the Codex how does it look like
   in WP 2.x
 *  Thread Starter [xinfo](https://wordpress.org/support/users/xinfo/)
 * (@xinfo)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450612)
 * i can able to find only this link [http://codex.wordpress.org/User:Tomhanna/Adding_Ads_to_Wordpress](http://codex.wordpress.org/User:Tomhanna/Adding_Ads_to_Wordpress)
 * but it look for older version help me to find for new version for placing ad 
   between the post
 * thanks
 *  [whooami](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450616)
 * your close,
 * `<?php if (have_posts()) : while (have_posts()) : the_post(); ?>`
 *  Thread Starter [xinfo](https://wordpress.org/support/users/xinfo/)
 * (@xinfo)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450618)
 * ah i want to use this code
    <?php $postnum = 1; $showads = 5; ?> <?php if ($posts):
   foreach ($posts as $post) : start_wp(); ?> <?php the_content(); ?> <?php if (
   $postnum == $showads) { ?> <<ADD ADVERTISING HERE>> <?php } $postnum++; ?> <?
   php endforeach; else: ?> There are no posts! <?php endif; ?>
 * to place the in between the post need help whn i add this code i get error
 * well do i have to add above code after this code
    <?php if (have_posts()) : while(
   have_posts()) : the_post(); ?>
 *  Thread Starter [xinfo](https://wordpress.org/support/users/xinfo/)
 * (@xinfo)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450639)
 * Hope some one help me i able to find instruction for old version not for new 
   version, and i don’t want to use any plugin.
 *  Thread Starter [xinfo](https://wordpress.org/support/users/xinfo/)
 * (@xinfo)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450665)
 * well i solved my own question my self with the help of
 * [http://www.tamba2.org.uk/wordpress/adsense/](http://www.tamba2.org.uk/wordpress/adsense/)

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Placing code in index.php need help’ is closed to new replies.

## Tags

 * [index](https://wordpress.org/support/topic-tag/index/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [xinfo](https://wordpress.org/support/users/xinfo/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/placing-code-in-indexphp-need-help/#post-450665)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
