Title: Alternating posts
Last modified: August 19, 2016

---

# Alternating posts

 *  [wheresrhys](https://wordpress.org/support/users/wheresrhys/)
 * (@wheresrhys)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/alternating-posts/)
 * In order to put ads on my site, but only every few posts, I want to add a simple
   conditional to the bottom of each post, containing my ad code.
 * I have ssomething like the following:
    <?php if (the_ID() % 3 == 0){ ?> ad code
 * <?php } ?>
 * But all this does is echo the id of the post…. for EVERY post!
 * What am I doing wrong?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/alternating-posts/#post-1053189)
 * Try using $post->ID, as [the_ID](http://codex.wordpress.org/Template_Tags/the_ID)
   is intended to display the ID of a post.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/alternating-posts/#post-1053227)
 * Also see you got an answer here: [http://stackoverflow.com/questions/763179/alternate-posts-in-wordpress](http://stackoverflow.com/questions/763179/alternate-posts-in-wordpress)

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

The topic ‘Alternating posts’ is closed to new replies.

## Tags

 * [Alternate](https://wordpress.org/support/topic-tag/alternate/)
 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 2 replies
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/alternating-posts/#post-1053227)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
