Support » Themes and Templates » Every X# of posts do something?

  • Resolved Aaron


    How can I do this. I am looking through the forum and the codex, and I cannot come up with a solution.
    I have found this
    and it does some of what I am looking for. Is there a function built in to WP or a implementation of the above link that will do something every certain number of posts?
    For example:
    post 1
    post 2
    post 3
    post 4
    post 5
    post 6
    post 7
    post 8
    post 9
    …and so on and so on no matter how many posts are on the page.

Viewing 1 replies (of 1 total)
  • Got it!!!
    With a little bit of help from over at the MU forums.

    This is what was done to allow a “do something insertion” every X number of posts. Based on Adsense by Podz (link above).
    In the case below every four posts “help” is inserted.

    <!--Before Loop-->
    $postnum = 1;
    $showadsense1 = array(4, 8, 12, 16, 20, 24, 28, 32);
    <!--before enwhile-->
    <?php if ( in_array($postnum, $showadsense1) ) {
    echo 'help';
    } ?>
    <?php $postnum++; ?>

    I am using this to create thumbnail galleries. This is for a photo project site that I have created. In my category/archive template is set to display only the thumbnail of each entry, I have then floated the div, and with the above script inserted a <br clear="all"> to force the next “row”.

    Hope this helps someone.

Viewing 1 replies (of 1 total)
  • The topic ‘Every X# of posts do something?’ is closed to new replies.