【问题标题】:Stuck with WordPress ACF plugin坚持使用 WordPress ACF 插件
【发布时间】:2017-03-16 04:07:41
【问题描述】:

我遇到了一个简单的 WordPress 问题。我正在使用 ACF 插件,但似乎无法让它在页面上显示该字段。我的 page.php 文件如下所示:

  <?php get_header(); ?>

  <?php get_sidebar(); ?>



      <div id="main">
        <div id="content">
        <?php if (have_posts()) : ?>

        <!-- Starting the loop -->  
        <?php while (have_posts()) : the_post(); ?>
          <div <?php post_class() ?>>
            <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
          </div>

        <?php the_content(''); ?>


        <?php endwhile; ?>
        <h2><?php the_field('bottom'); ?></h2>
        <?php else : ?>

            <h1>Nothing Found</h1>
            <p>Sorry but we cant find anything</p>

        <?php endif; ?>


        </div>
      </div>

<?php get_footer(); ?>

据我所知,这真的很简单。在将 ACF 用于更技术性的东西之前,我只是将其作为练习来掌握 ACF,我被难住了!

该字段是“底部”,我只想在循环之后将文本粘贴在那里。

Screen shot of the custom field in the plugin

我猜这将是一件非常简单的事情,但似乎无法在任何地方找到答案!

【问题讨论】:

  • 你确定你已经给这个特定页面的字段一个值,否则你可以将目标页面的 postId 作为第二个参数添加到函数中。
  • 谢谢伙计……真的就是这么简单。为您的帮助干杯,只需要点击页面上的更新.... duhhh :o)
  • 很高兴您的问题得到解决。

标签: php wordpress advanced-custom-fields


【解决方案1】:

(代表 OP 发布解决方案)

正如预期的那样,答案很简单。添加自定义字段模板后,我没有在特定页面上单击更新!简单但同样令人沮丧。感谢您的帮助。

【讨论】:

    猜你喜欢
    • 2020-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-16
    • 2015-11-06
    • 2017-03-28
    • 2014-06-12
    • 1970-01-01
    相关资源
    最近更新 更多