【问题标题】:Post content is not displaying ACF帖子内容不显示 ACF
【发布时间】:2018-01-10 03:00:48
【问题描述】:

为什么我看不到帖子内容,如果我进行 wordpress 搜索,我可以很容易地看到帖子标题。我有一个自定义帖子类型“艺术家”,我正在使用 ACF。

            <?php
            if ( have_posts() ) : ?>

            <?php
             /* Start the Loop */
             while ( have_posts() ) : the_post(); ?>






           <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
           <header class="entry-header">
           <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>

              </header><!-- .entry-header -->

             <div class="entry-summary">
             <?php the_content(); ?>
              </div><!-- .entry-summary -->

             <footer class="entry-footer">
             <?php edigital_entry_footer(); ?>
             </footer><!-- .entry-footer -->
             </article><!-- #post-## -->

【问题讨论】:

  • 请澄清您的问题... the_content 不是 acf 的一部分。实际上提供的代码中没有acf函数。
  • 我正在使用 ACF,并且我有一个自定义帖子类型“团队”。除了“团队”之外,我已禁用搜索结果中的所有帖子类型。现在,当我搜索“John”时。它只显示标题和永久链接。我似乎无法显示“约翰”下的内容
  • 如果你上面贴的代码是搜索结果页面,那么你需要按照下面@CKG的例子,把你的代码包装在wp循环中。
  • 我更新了上面的代码。它仍然只显示标题和永久链接
  • 嗨@user3678230 你在哪里执行“我已从搜索结果中禁用除“团队”之外的所有帖子类型”?抱歉,我无法理解问题所在。

标签: php wordpress advanced-custom-fields


【解决方案1】:

您需要将 "the content" 函数调用放在 WordPress 循环中,以便它将您的内容输出到页面,如下所示。

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>

希望对你有帮助,干杯!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    • 1970-01-01
    • 2016-04-07
    • 1970-01-01
    • 2011-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多