Created
February 7, 2013 13:37
-
-
Save neverything/4730968 to your computer and use it in GitHub Desktop.
Sample index.php file to show how you could create a new row after two posts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sample index.php file for displaying two posts per row | |
*/ | |
get_header(); ?> | |
<!-- Row for main content area --> | |
<div id="content" class="row"> | |
<div id="main" class="twelve columns" role="main"> | |
<div class="post-box"> | |
<?php if ( have_posts() ) : ?> | |
<?php | |
(int) $posts_counter = 1; // Initiate custom counter | |
while ( have_posts() ) : the_post(); | |
if ( $posts_counter % 2 == 1 ) { | |
echo '<div class="row">'; // draw the opening div.row | |
} | |
?> | |
<div class="six columns"> | |
<?php get_template_part( 'content', get_post_format() ); ?> | |
</div> | |
<?php | |
// Make sure we close the row after the last post anyways. | |
if ( $posts_counter % 2 == 0 || $posts_counter == $wp_query->post_count ) { | |
echo '</div>'; // draw the closing div.row | |
} | |
$posts_counter++; // +1 for the counter | |
endwhile; | |
?> | |
<?php else : ?> | |
<?php get_template_part( 'content', 'none' ); ?> | |
<?php endif; ?> | |
<?php if ( function_exists( 'required_pagination' ) ) { | |
required_pagination(); | |
} ?> | |
</div> | |
</div><!-- /#main --> | |
</div><!-- End Content row --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment