【发布时间】:2017-05-25 02:52:56
【问题描述】:
我已经尝试过这里发布的解决方案。 https://stackoverflow.com/a/19695851/7244133
还有这个……https://scotch.io/bar-talk/different-tricks-on-how-to-make-bootstrap-columns-all-the-same-height
这些似乎都不适用于循环。有任何想法吗?谢谢!
<div class="container my-container">
<?php
$args=array(
'post_type' => 'post',
'category_name' => 'Business',
'posts_per_page' => 3
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
$i = 0;
while ($my_query->have_posts()) : $my_query->the_post();
// modified to work with 3 columns
// output an open <div>
if($i % 3 == 0) { ?>
<div class="row is-flex">
<?php
}
?>
<div class="col-md-4">
<div class="grid-loop">
<div class="custom-border">
<a class="perm_link" href="<?php the_permalink(); ?>">
<h2><?php the_title(); ?></h2>
<div class="blog-image image-responsive"><?php the_post_thumbnail('img-251x250'); ?></div></a>
<p><?php the_excerpt(); ?></p>
<span class="shortlink">
<button class="btn btn-success"><?php the_shortlink("Read More"); ?></button>
</span>
</div>
</div>
</div>
<?php $i++;
if($i != 0 && $i % 3 == 0) { ?>
</div><!--/.row-->
<div class="clearfix"></div>
<?php
} ?>
<?php
endwhile;
}
wp_reset_query();
?>
</div><!--/.container-->
【问题讨论】:
-
“这些似乎都不适用于循环。” - 这些都关心 循环,只关心生成的 HTML 结构。您是否已确认这是应有的?
标签: javascript html css wordpress twitter-bootstrap