我目前有一个循环,用于显示自定义帖子类型,从自定义字段到带有指示器的Bootstrap Carousel。事实是,自定义帖子类型有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
答案 0 :(得分:0)
您似乎正在使用“高级自定义字段”来保存存储在“ choose_testimonials”中的内容。根据我在这里看到的信息,我认为高级自定义字段中针对该特定字段的设置不正确。
如果不是这种情况,则说明您使用的包装器或WordPress模板不正确。我们需要有关这些事项的更多信息以帮助您!