Last active
March 28, 2016 01:24
-
-
Save s-hiroshi/c84c9acea4363d88ad6f to your computer and use it in GitHub Desktop.
WordPressの投稿ループでBoostrapを使い3列表示するサンプルです。
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 | |
global $posts; | |
$num = 1; | |
?> | |
<?php foreach ( $posts as $post ) : setup_postdata( $post ); ?> | |
<?php if ( 1 === $num || 1 === ( $num % 3 ) ) : ?> | |
<div class="row"> | |
<?php endif; ?> | |
<div class="col-lg-4"> | |
<div class="thumb-panel__img"> | |
<a href="<?php echo esc_url( get_permalink() ); ?>"> | |
<?php the_post_thumbnail(); ?> | |
</a> | |
</div> | |
</div> | |
<?php if ( ( 0 === ( $num % 3 ) && 1 !== $num ) || count( $posts ) === $num ) : ?> | |
</div> | |
<!-- .row --> | |
<?php endif; ?> | |
<?php $num ++; ?> | |
<?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment