• Hello,

    I’m am using two loops in the homepage, let say featured post and normal posts, and looking for solution for my problems.

    Using this layout, I would need two loops to make it run properly. My problem is: when I break the first loop with theses codes:

    <?php static $ctr = 0;
    if ($ctr == “1”) { break; }
    else { ?>

    <?php $ctr++; } ?>

    There’s a featured post section as I want. But, instead of begin with the second most recent post, the second loop shows the third recent post as the first post.

    Any help would be appreciated. And sorry for my bad English. And I hope I make myself clear.

    Thanks

Viewing 1 replies (of 1 total)
  • You may be better off just testing off the $posts object (and current $post) in The Loop for this, instead of building a counter. So in the first loop:

    <?php if( $posts[0] != $post ) { break; } ?>

    In your second loop, do something like:

    <?php if( $posts[0] != $post ) { ?>
    
    ~Display post~
    
    <?php } ?>

    And your English is fine. ;)

Viewing 1 replies (of 1 total)
  • The topic ‘Loop breaking need help’ is closed to new replies.