Friday, April 29, 2011

Alternate posts in wordpress

In order to put ads on my wordpress 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?

From stackoverflow
  • What the_ID does is simply to echo the ID of the current post.

    If you want to get the ID, use get_the_ID() instead.

    wheresrhys : fantastic - thanks

0 comments:

Post a Comment