Conditional Loop: What's wrong?
-
Trying to use conditional statements in loop to apply different bootstrap classes to different posts. What am I doing wrong, here? Thx, in advance, for your help.
<?php while ( have_posts() ) : the_post(); ?> <?php if ( $wp_query-> current_post == 1 ) && !is_paged() : ?> <div class="container"> <div class="row"> <div class="span12"> <h1> <?php the_title(); ?> </h1> <p> <?php the_excerpt(); ?> </p> </div> <!-- .span12 --> </div> <div class="row"> <?php else if ( $wp_query-> current_post == 2 || $wp_query-> current_post == 3 || $wp_query-> current_post == 4 && !is_paged() ) : ?> <div class="span4"> <h2> <?php the_title(); ?> </h2> <p> <?php the_excerpt(); ?> </p> </div> <!-- .span4 --> <?php else if ( $wp_query-> current_post == 5 && !is_paged() ) : ?> </div> <!-- .row --> <div class="row"> <div class="span3"> <h2> <?php the_title(); ?> </h2> <p> <?php the_excerpt(); ?> </p> </div> <!-- .span3 --> <?php else if ( $wp_query-> current_post == 6 || $wp_query-> current_post == 7 || $wp_query-> current_post == 8 && !is_paged() ) : ?> <div class="span3"> <h2> <?php the_title(); ?> </h2> <p> <?php the_excerpt(); ?> </p> </div> <!-- .span3 --> <?php else if ( $wp_query-> current_post == 8 && !is_paged() ) : ?> <div class="span3"> <h2> <?php the_title(); ?> </h2> <p> <?php the_excerpt(); ?> </p> </div> <!-- .span3 --> </div> <!-- .row --> </div> <!-- .container --> <?php else : ?> <p> Error. </p> <?php endif; ?> <?php endwhile; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Conditional Loop: What's wrong?’ is closed to new replies.