【发布时间】:2019-06-16 07:35:47
【问题描述】:
我在 WordPress 项目上工作,我在一个名为 testimonials.php 的特殊文件中创建了推荐信,并通过 get_template_part 在关于我们的页面上调用了该文件,它工作正常,但是当我调用 (testimonials.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']; ?>
【问题讨论】:
标签: php wordpress advanced-custom-fields