2016-07-19 2 views
0
<?php 
$wpb_all_query = new WP_Query(
    array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1) 
); 

if ($wpb_all_query->have_posts()) : ?> 

    <?php while ($wpb_all_query->have_posts()) : $wpb_all_query->the_post(); 
     $cats = get_the_category(); 
     if ($cats[0]->cat_name === 'Coaching') { ?> 
      <div class="callout horizontal"> 

       <?php the_post_thumbnail() ?> 

       <div class="content"> 
        <h5><?php the_title(); ?></h5> 
        <?php the_content(); ?> 
       </div> 

      </div> 
     <?php } ?> 
    <?php endwhile; ?> 

<?php endif; ?> 

위 코드는 제거 할 때 <?php echo get_field('column_two'); ?> 코드가 실행되도록합니다.템플릿에 게시물을 출력하면 그 아래에있는 태그가 에코로 표시되지 않습니다.

내 질문은 단순히 왜 코드 내 <?php echo get_field('column_two'); ?>

+0

''줄에 세미콜론';'이 누락되었습니다. – coderodour

+0

사실 고마워하지만 문제가 해결되지 않았습니다. – MaxwellLynn

+0

PHP 태그를 닫으면 세미콜론이 자동으로 추가됩니다. –

답변

1

당신이하려는 경우 get_field ('column_two')의 반향을 차단 이상; inside while 루프, WordPress는 게시물 내부에서 column_two 사용자 정의 필드를 찾을 것입니다.하지만 이는 게시물과 페이지에 존재하지 않는 것으로 보입니다.

get_field ('column_two')에 액세스하려는 경우; while 루프 후에는 post 데이터 wp_reset_postdata()를 재설정해야합니다. 참조 : https://codex.wordpress.org/Function_Reference/wp_reset_postdata

희망이 도움이된다.

+0

거룩한 머핀 ... 이것은 마술을했다 ... 이것이 필요한 이유는 어리 석다 ... 당신의 anawer를위한 감사합니다 – MaxwellLynn

관련 문제