2016-06-01 124 views
0

由於比Wordpess社區更好的響應率而在此處詢問。自定義帖子類型中未顯示高級自定義字段UI

我設置了一個名爲Training Services的自定義帖子類型。我創建了一個名爲content_snippet的自定義字段,並將其分配爲僅適用於相關的帖子類型。我在帖子類型編輯屏幕上看到了該字段,並輸入了一些Lorem ipsum。

我的代碼實現如下(content-page.php):爲什麼帖子類型的標題,內容和縮略圖顯示在前端而不是自定義字段?它只是顯示一個空的標籤,如果我在chrome開發工具中查看它,lorem應該是。

在此先感謝您的幫助!

<!-- Custom Fields 
================================================== --> 
<?php 
$content_snippet = get_field('content_snippet'); 
?> 

<section class="container-fluid section-spacing" style="border:1px solid black;"> 
    <div class=" text-align-center row" style="border:1px solid green;"> 

     <h1><?php the_title(); ?></h1> 
     <hr class="headingUnderline"> 
     <div class="responsiveShrink" style="border:1px solid yellow;"><?php the_content() ; ?></div> 

     <?php $loop = new WP_Query(array('post_type' => 'training_services', 'orderby' => 'post_id', 'order' => 'ASC')); ?> 

     <?php while($loop->have_posts()) : $loop->the_post(); ?> 

     <div class="text-align-center col-xs-12 col-sm-6" style="border:1px solid red;"> 
      <div class="postWrapper"> 


       <div class="imageWrapper"> 

        <?php 
        if (has_post_thumbnail()) { 
         the_post_thumbnail(); 
        } 
       ?> 

       </div> 
       <div class="postContentWrapper"> 


        <h3><?php the_title(); ?></h3> 
        <div><?php echo $content_snippet; ?></div> 
        <div><?php the_content(); ?></div> 

       </div> 



      </div> 
     </div> 

     <?php endwhile; wp_reset_query(); ?> 
    </div> 
</section> 

回答

0

愚蠢的錯誤。自定義字段必須在循環內聲明。留給未來的讀者。

相關問題