WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Wrap every 2 posts with a row-fluid (3 posts)

  1. bryananthonylewis
    Member
    Posted 1 year ago #

    I'm trying to wrap every 2 posts with a class of "row-fluid"... html example below...

    <div class="row-fluid">
        <div class="post 1"></div>
         <div class="post 2"></div>
    </div>
    <div class="row-fluid">
        <div class="post 1"></div>
         <div class="post 2"></div>
    </div>

    Right now I have the following html output

    <div class="row-fluid">
        <div class="post 1"></div>
         <div class="post 2"></div>
         <div class="post 3"></div>
         <div class="post 4"></div>
    </div>

    I'd like to set a count loop if its at all possible to achieve wrapper every two posts so I can use twitter bootstrap properly without having to tweak the css and over-ride what bootstrap already has.

    <?php
    
    					$args = array( 'post_type' => 'mysite_team', 'posts_per_page' => 10 );
    					$loop = new WP_Query( $args );
    					while ( $loop->have_posts() ) : $loop->the_post();
    
    						echo '<div ';
    							$even_odd = (++$j % 2 == 0) ? 'featured-image-wrapper-even-post span6' : 'featured-image-wrapper-odd-post span6'; post_class( $even_odd );
    						echo '>';
    
    						echo '<h1>';
    						echo '<a href="';
    							the_permalink();
    						echo '">';
    							the_title();
    						echo '</a></h1>';
    
    						echo '<div class="featured-image alignleft">';
    						echo '<a href="';
    							the_permalink();
    						echo '">';
    							the_post_thumbnail('team-thumbnail-size');
    						echo '</a>';
    						echo '</div>';
    
    						echo '<div class="entry-content">';
    							the_excerpt();
    						echo '<p><a href="';
    							the_permalink();
    						echo '"><i>Read More';
    						echo '</i></a></p>';
    						echo '</div>';
    
    						echo '</div>';
    
    					endwhile;
    
    					?>

    Any help would be awesome as I have tried a few things but keep getting white pages and no errors to go off of.

    Thanks in advance!

  2. bryananthonylewis
    Member
    Posted 1 year ago #

    Brain fart... I figured it out! Thanks for taking a look!

  3. simenschi
    Member
    Posted 1 year ago #

    Could you please share your solution?

    I need to wrap every two posts as well, like this:

    <div class="wrap">
        …post1
        …post2
    </div>
    <div class="wrap">
        …post3
        …post4
    </div>

Topic Closed

This topic has been closed to new replies.

About this Topic