循环播放每行3个帖子。无法在每个帖子周围制作边框。相反,它会制作一个边框,覆盖网格上延伸到底部帖子的顶部帖子。请参阅screenshotWordPress后循环的边框,使用引导程序的网格
我试着添加一个不同于此处使用的泛型选择器的类名,但似乎没有工作。任何意见,将不胜感激。第一个使用WordPress和Bootstrap的项目。使用Sass进行造型,因此部分div。提前致谢!
.col-sm-4 {
border: 1px solid gray;
}
<section id="blog-section">
<div class="container">
<div class="col-sm-12">
<h1>Blog Title</h1>
</div>
<div class="row">
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-4 text-center">
<?php $i = 1 ?>
<?php $posts = get_posts(array(
'post_type' => 'post',
'posts_per_page' => -1
));
foreach ($posts as $post) : start_wp(); ?>
<?php if ($i == 1): ?>
<a class="perm_link" href="<?php the_permalink(); ?>">
<h2><?php the_title(); ?></h2>
<div class="blog-image image-responsive"><?php the_post_thumbnail('thumbnail'); ?></div></a>
<p><?php the_excerpt(); ?></p>
<span class="shortlink">
<?php the_shortlink("Read More"); ?>
</span>
<?php endif; ?>
<?php if($i == 3){$i = 1;} else {$i++;} ?>
<?php endforeach; ?>
</div>
<div class="col-sm-4 text-center">
<?php $i = 1 ?>
<?php $posts = get_posts(array(
'post_type' => 'post',
'posts_per_page' => -1
));
foreach ($posts as $post) : start_wp(); ?>
<?php if ($i == 2): ?>
<h2><?php the_title(); ?></h2>
<div class="blog-image image-responsive"><?php the_post_thumbnail('thumbnail'); ?></div>
<p><?php the_excerpt(); ?></p>
<span class="shortlink">
<?php the_shortlink("Read More"); ?>
</span>
<?php endif; ?>
<?php if($i == 3){$i = 1;} else {$i++;} ?>
<?php endforeach; ?>
</div>
<div class="col-sm-4 text-center">
<?php $i = 1 ?>
<?php $posts = get_posts(array(
'post_type' => 'post',
'posts_per_page' => -1
));
foreach ($posts as $post) : start_wp(); ?>
<?php if ($i == 3): ?>
<h2><?php the_title(); ?></h2>
<div class="blog-image image-responsive"><?php the_post_thumbnail('thumbnail'); ?></div>
<p><?php the_excerpt(); ?></p>
<span class="shortlink">
<?php the_shortlink("Read More"); ?>
</span>
<?php endif; ?>
<?php if($i == 3){$i = 1;} else {$i++;} ?>
<?php endforeach; ?>
</div>
</div>
</div>
</section>
谢谢你的!我的想法是col标签将包括整个帖子,但是短视。是的,知道使用Bootstrap的类会很糟糕,但我使用Sass进行编码,并且会嵌套在section标签下,从而避免在其他页面/部分发生冲突。 我的最终解决办法如下。 – Rick