我在WordPress项目中工作,我在一个名为推荐的特殊文件中创建了推荐。php和我通过get\\u template\\u part调用了页面上关于我们的文件,它工作得很好,但当我调用(estimationals.php)到主页时,并没有显示所有值。
使用高级自定义字段插件
<!-- Start Section Testimonials -->
<section class="testimonials section-padding">
<div class="carousel-right col-lg-7 col-md-7 col-sm-7 col-xs-12">
<div class="owl-carousel">
<?php $testimonials = array (\'post_type\' => \'Testimonials\' , \'order\' => \'ASC\');
$query = new wp_query($testimonials);
if ($query->have_posts()) {
while ($query->have_posts()){
$query->the_post(); ?>
<!-- Start Item 1 -->
<div class="testimonials-item">
<!-- Testimonials Text -->
<div class="testimonials-text-item">
<?php the_content(); ?>
</div>
<!-- Testimonials Title -->
<div class="testimonials-title clearfix">
<!-- Title Img -->
<div class="title-img">
<img src="<?php the_field(\'image\'); ?>" alt="testimonials">
</div>
<!-- Title Text -->
<div class="title-text">
<h3><?php the_title(); ?></h3>
<p><?php the_field(\'small_title\'); ?></p>
</div>
</div>
</div>
<!-- End Item 1 -->
<?php }} ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<!-- Start Title -->
<?php $testimonials = get_field(\'testimonials\'); ?>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-5 col-md-5 col-sm-4 col-xs-12">
<div class="testimonials-text clearfix">
<div class="title">
<span><?php echo $testimonials[\'small_title\']; ?></span>
<h2><?php echo $testimonials[\'main_title\']; ?></h2>
</div>
<div class="text-p">
<?php echo $testimonials[\'description\']; ?>
</div>
</div>
</div>
</div>
</div>
<!-- End Title -->
</section>
未从所有值中显示的零件
<span> <? php echo $ testimonials [\'small_title\']; ?> </ span>
<h2> <? php echo $ testimonials [\'main_title\']; ?> </ h2>
<? php echo $ testimonials [\'description\']; ?>