duan201444
2015-11-13 17:45
浏览 83
已采纳

运行循环后ACF未显示

In the below code, I call fields from Advanced Custom Fields plugin and only the first two show 'home_title' and 'home_content'. After these two I run two different loops to show the latest posts in a given category. After those loops run there are 4 more fields from ACF called. 'donate_title' , 'donate_content' , 'mission_title' , 'mission_content'. Which are not showing up (not pulling any content at all).

If I move these ACF before running the loops they all show up correctly. So I imagine there is a problem with these following the loops but cannot find the reason.

<div class="main-site">
<div class="home-title-1">
<?php the_field('home_title'); ?>
</div>
<div class="home-content-1">
<?php the_field('home_content'); ?>
</div>

<div class="home-boxes-cont">
<div class="box-left">
<?php
query_posts('cat=4&posts_per_page=1');
while (have_posts()) : the_post(); ?>
    <div class="bl-img">
    </div>
    <div class="bl-title">
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </div>
    <div class="bl-content">
    <?php the_excerpt(); ?>
    </div>
<?php endwhile; ?>
</div>

<div class="box-middle">
<?php
query_posts('cat=5&posts_per_page=1');
while (have_posts()) : the_post(); ?>
    <div class="bm-img">
    </div>
    <div class="bm-title">
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </div>
    <div class="bm-content">
    <?php the_excerpt(); ?>
    </div>
<?php endwhile; ?>
</div>

<div class="box-right">
    <div class="br-img">
    </div>
    <div class="br-title">
    <?php the_field('donate_title'); ?>
    </div>
    <div class="br-content">
    <?php the_field('donate_content'); ?>
    </div>
</div>
</div>

<div class="mission-title">
    <?php the_field('mission_title'); ?>
</div>
<div class="mission-content">
    <?php the_field("mission_content"); ?>
</div>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题