Support » Fixing WordPress » Multiple Loops Question

  • Resolved Syni


    Well, I searched but couldn’t find this case. I know you can do this with MT. But here’s my problem in as simple of a manner as I can explain it.

    Front page:
    Most recent post
    — AD (or something else) —
    Next post.

    (It seems like [Tempus Fugit] has something like that, but by date)

    So how do I modify the loop to do that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • You’re just looking to place ads within The Loop? Check out this plugin:

    A do it yourself method would involve setting up your own variable to count off posts, which you test to determine when to display the ad. For example, at the start of the Loop:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Insert your variable with the auto-increment operator (++):

    <?php if (have_posts()) : while (have_posts()) : the_post(); $post_num++; ?>

    Then right after this line place:

    <?php if(2 == $post_num) : ?>
    ~ your ad code goes here ~
    <?php endif; ?>

    This will insert the ad before the second (2) post.

    Great thanks. I also wanted to see if I could style the 1st post and the rest of them differently, so that do it yourself method looks best to me. Really appreciate the help!

    Tasty, Kafkaesqui. That’s just what I needed too. Much thanks.

    Moderator Matt Mullenweg



    This section from the Codex may be helpful:

    Thanks Matt, although I wanted a more specific answer which is why I asked the quesiton. I stared at that page for at least a half an hour and really didn’t pull anything out of it other than the fact that I can use the rewind_loop() function (should that be in the top example as well?) like it doesn’t say anything about how to start the 2nd loop at the 2nd post and use the first loop to display only the most recent post or date.

    Any other views on this topic?

    Moderator Matt Mullenweg



    Basically you have to manipulate the query string that’s passed to the loop function as you would in the address URI. Try experimenting with different arguments in after index.php and you should be able to find the proper combo you need for query posts.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Multiple Loops Question’ is closed to new replies.