主题中显示的ACF字段

时间:2019-04-18 01:13:22

标签: php wordpress hook advanced-custom-fields

我需要在主题中显示我的AFC字段。我的主题所有者说我,您应该编辑single-room-type.php文件。但是我找不到我应该在此文件中添加ACF代码的位置。我想我必须编辑另一个文件。任何想法如何做到这一点?

<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>

1 个答案:

答案 0 :(得分:0)

//-----------------------------------------------------
// 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 {