首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ACF字段在主题中显示

ACF字段在主题中显示
EN

Stack Overflow用户
提问于 2019-04-18 09:13:22
回答 1查看 83关注 0票数 0

我需要在我的主题中显示我的AFC字段。我的主题所有者告诉我,你应该编辑单间type.php文件。但是我找不到我应该在这个文件的什么地方添加我的ACF代码。我想我必须编辑另一个文件。你知道该怎么做吗?

代码语言:javascript
复制
<section class="content-editor">
<?php
while ( have_posts() ) : the_post();

    if ( post_password_required() ) {
        echo get_the_password_form();
        return;
    }
    ?>

        <?php do_action( 'mphb_render_single_room_type_before_content' ); ?>

        <?php
        /**
         * @hooked \MPHB\Views\SingleRoomTypeView::renderTitle              - 10
         * @hooked \MPHB\Views\SingleRoomTypeView::renderFeaturedImage      - 20
         * @hooked \MPHB\Views\SingleRoomTypeView::renderDescription        - 30
         * @hooked \MPHB\Views\SingleRoomTypeView::renderPrice              - 40
         * @hooked \MPHB\Views\SingleRoomTypeView::renderAttributes         - 50
         * @hooked \MPHB\Views\SingleRoomTypeView::renderCalendar           - 60
         * @hooked \MPHB\Views\SingleRoomTypeView::renderReservationForm    - 70
         */
        //do_action( 'mphb_render_single_room_type_content' );
        ?>

    <?php the_content(); ?>

    <?php do_action( 'mphb_render_single_room_type_after_content' ); ?>

<?php
endwhile;
?>
</section>
EN

回答 1

Stack Overflow用户

发布于 2019-04-18 13:19:11

代码语言:javascript
复制
//-----------------------------------------------------
// Single Output
//-----------------------------------------------------
if(is_single()){ ?>
  <section class="content-editor">
    <?php while (have_posts()) : the_post(); ?>

        <!-- Add your acf field here -->
        <div class="your-acf-field"><?php echo get_field('your_acf_field', 
          get_the_ID());?></div>

        <?php the_content(); ?>
    <?php endwhile; ?>
  </section>
 <?php } else {
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55737878

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档