php - Wordpress Post Carousel - 如何自动填充?
问题描述
我正在创建一个网站,我希望最新帖子在导航栏下方的页面顶部轮播。我使用 Bootstrap 作为主题,使用 Owl-carousel 作为轮播本身,使用 Wordpress 作为帖子等。在以这种方式使用 Wordpress 时,我仍然是一个新手,希望能得到一些帮助!
我已经尝试使用填充轮播,<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
并且我认为它创建 3 个单独的轮播而不是填充第一个的原因是因为这个,但我不确定如何修复它。
<div class="container">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="owl-carousel owl-theme">
<div class="item">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src=".../100px180/" alt="Card image cap">
<div class="card-body">
<h5 class="card-title"><?php the_title(); ?></h5>
<p class="card-text"><?php the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>" class="btn btn-success"> Read More</a>
</div>
</div>
</div>
</div>
<?php endwhile;
endif; ?>
</div>
我需要它,而不是创建 3 个单独的轮播,而是用 Wordpress 的最新帖子填充一个。非常感谢所有帮助!
解决方案
@Scuzzy 回答了问题,现在已修复。while 循环处于错误的级别。谢谢您的帮助。
推荐阅读
- javascript - 输入状态未正确更新 - 反应
- rest - 如何在 Trello API 中设置卡片封面的颜色?
- c - 在程序中更改输入流
- excel - 在 VBS 文件中使用通配符查找器打开 Excel 文件
- kubernetes - 如何创建具有默认 uid:gid 和多个组访问 gids(4 到 5)的 pod,这是访问 nfs 共享所需的。?
- azure-pipelines - Azure DevOps 代理池的最佳实践
- cpu - RiscV 转发,我们为什么不需要它?
- javascript - 即使单词之前或之后有文本,如何读取字符串?
- react-native - 如何在自己的文件中正确实现 React Native 中的自定义组件?
- javascript - 使用 Javascript 通过 JSON 查询类别