WordPress.org

Ready to get started?Download WordPress

Forums

Alternating posts (3 posts)

  1. wheresrhys
    Member
    Posted 5 years ago #

    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?

  2. MichaelH
    Member
    Posted 5 years ago #

    Try using $post->ID, as the_ID is intended to display the ID of a post.

  3. MichaelH
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic