doulei8475 2016-01-13 19:10
浏览 51
已采纳

Wordpress高级自定义字段 - 显示在PAGE模板上

I am using Advanced Custom Fields with Wordpress. I have set up a field and can display it on my homepage/front-page.php template like this...

<?php the_field('primary_tagline'); ?>

I want to use the same field on my page.php template, but when i drop in the same code, no results are returned. I don't understand why it works on one template but not the other. Do i need different code to show the same field results across multiple templates? Here is the code...

   <?php the_field('primary_tagline'); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'template-parts/content', 'page' ); ?>
                <?php
                    if ( comments_open() || get_comments_number() ) :
                        comments_template();
                    endif;
                ?>
            <?php endwhile; ?>
        </main><!-- #main -->
    </div><!-- #primary -->

Is it a loop problem? ACF won't show outside a loop?

  • 写回答

5条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥100 制作短链接和api接口的
      • ¥15 星河亮点sp9500测试指导
      • ¥15 dataframe 某列数据分列
      • ¥15 风扇导入fluent后仿真压力和速度数据卡在旋转域
      • ¥15 echarts中dataZoom报错
      • ¥15 求解答:《前端综合基础》作为一门课程的话,应该包含哪些内容?
      • ¥15 软件原型系统开发+实例测试
      • ¥50 C#上位机调试Win USB
      • ¥15 java基础望榜榜 java基础望榜榜
      • ¥15 comsol 周期性端口