在我的HTML模型中,我的想法是将缩略图并排显示,我正在使用以下代码:
<div class="jumbotron">
<img src="<?php print IMAGES; ?>/th1.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th2.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th3.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th4.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th5.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th6.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th7.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th8.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th3.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th5.png" class="img-thumbnail">
<img src="<?php print IMAGES; ?>/th2.png" class="img-thumbnail">
<br /><br />
<button type="button" class="btn btn-xs btn-warning">VER TODOS LOS ESTRENOS</button>
</div>
此处的图像:
然而,当使用wordpress尝试同样的事情时,一切都很奇怪,我需要“调用”点击类别中的所有帖子,只带上特色图片,因此每个图片将并排对齐,就像上面的HTML示例一样,我使用的是:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<br />
<div class="jumbotron">
<?php the_post_thumbnail(array(\'class\' => \'img-thumbnail\')); ?>
<br /><br />
<button type="button" class="btn btn-xs btn-warning">VER TODOS LOS ESTRENOS</button>
<?php endwhile; else: ?>
<p><?php _e(\'No posts were found. Sorry!\'); ?></p>
</div>
<?php endif; ?></p>
但不起作用
看起来像:
伙计们,知道为什么会这样吗?
最合适的回答,由SO网友:Nilambar Sharma 整理而成
您没有正确使用循环。未测试,但您可以尝试以下操作:
<?php if (have_posts()) : ?>
<br />
<div class="jumbotron">
<?php while (have_posts()) : the_post(); ?>
<?php the_post_thumbnail(array(\'class\' => \'img-thumbnail\')); ?>
<?php endwhile; ?>
<br /><br />
<button type="button" class="btn btn-xs btn-warning">VER TODOS LOS ESTRENOS</button>
</div>
<?php else: ?>
<p><?php _e(\'No posts were found. Sorry!\'); ?></p>
<?php endif; ?>