php - 引导轮播显示自定义分类而不是自定义帖子
问题描述
我目前有一个用于显示自定义帖子类型的循环,从自定义字段到带有指标的引导轮播。问题是,自定义帖子类型有 2 个类别(自定义分类法 company_testimonial 和 agent_testimonial),我只想显示其中一个。
我已经迷失了
<?php
$post_objects_testimonials = get_field('choose_testimonials');
if ($post_objects_testimonials):
?>
<!-- Section testimonials -->
<section class="testimonials">
<div class="container">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<?php
$count = count($post_objects_testimonials);
for ($i = 0; $i < $count; $i++) {
?>
<li data-target="#carouselExampleIndicators" data-slide-to="<?php
echo $i;
--------
?>" <?php
if ($i == 0) {
?>
<div class="active">
<?php
}
?>
</li>
<?php
}
?>
</ol>
<div class="carousel-inner">
<?php
$count = 0;
?>
<?php
foreach ($post_objects_testimonials as $post):
?>
<?php
foreach ($post_objects_testimonials as $post):
?>
<?php
setup_postdata($post);
$test_image = get_field('test_image');
$test_image_url = $test_image['url'];
$test_image_alt = $test_image['alt'];
?>
<div class="carousel-item
<?php
if ($count == 0) {
echo ' active';
}
?>">
<div class="row">
<div class="col-lg-11 mx-auto">
<?php
if (get_field('description')):
?>
<p class="quote-paragraph">
<?php
the_field('description');
?>
</p>
<?php
endif;
?>
<?php
if (get_field('description') && get_field('job_title') && get_field('name')):
?>
<p class="quote-author">
<strong><?php
the_field('name');
?></strong>
<?php
the_field('job_title');
?>
<?php
the_field('company');
?>
</p>
<?php
endif;
?>
</div>
<?php
$count++;
?>
</div>
</div>
<?php
endforeach;
?>
</div>
<div class="arrow-icons">
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
<?php
wp_reset_postdata();
?>
<?php
endforeach;
?>
<?php
endif;
?>
我希望显示分类 company_testimonial 但忽略 agent_testimonial
解决方案
看起来您正在使用高级自定义字段来保存存储在“choose_testimonials”中的内容。根据我在此处看到的内容,我假设该特定字段的高级自定义字段内的设置不正确。
如果不是这种情况,则您使用的包装器或 WordPress 模板不正确。我们需要更多关于这些事情的信息来提供帮助!
推荐阅读
- java - 在从数据库中获取详细信息之前,Android 适配器正在加载
- php - .htaccess 文件在将根文件夹重定向到文件时返回 404 错误
- selenium - Appium - 将许多设备注册到 selenium grid docker
- java - 可选的 orElse 意外抛出 NPE;取 null 作为值
- vba - 如何在没有编译/运行时错误的情况下识别损坏的 vba 代码?
- sql-server - 如何在sql中获取两个日期时间之间的小时数?
- javascript - onClick 锚标记使用 jquery 显示当前 div
- firebase - 存储标签以获得良好查询选项的方式?
- server-side - 通过 PHP 或 Javascript 构建 HTML 页面?服务器端与客户端
- java - 有没有一种方法可以像使用 ListView 或 RecyclerView 一样使用 firebaseUI 填充微调器项目?