-1
여기에 멍청한 놈. get_field에서 결과를 얻을 수 없습니다.WordPress 고급 사용자 지정 필드 리피터 필드 - 나를 위해 작동하지 않는 get_field
http://23.21.199.240/test
내가 FOR 루프와 중계기 필드 데이터를 검색 할 수 있지만, 특별한 ACF의 get_field 기능은 내가 예상했던 일을하지 않습니다 : 여기 내 테스트 페이지입니다. (너무 단순 해 보이므로 내가 완전히 골치 아픈 실수를 저 지르더라도 놀라지 않을 것입니다.)
어떤 도움을 주시면 감사하겠습니다!
<?php
/*
Template Name: test
*/
?>
<?php get_header(); ?>
<?php query_posts('category_name=worldwise&posts_per_page=3'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
id: <?php the_ID(); ?><br />
<!--let's try to display all the topics (an ACF repeater field) for this post....-->
<?php if(get_field('topic')): // if there are topics, get all their data in an array ?>
<?php
$topic_list_1 = ''; // set up an empty topic list
while(has_sub_field('topic')): // for every topic
$topic_title_1 = get_sub_field('topic_title'); // get the title
$topic_list_1 .= '<li>' . $topic_title_1 . '</li>'; // and add it to the topic list
endwhile; // no more topics, move on
?>
<p><strong>The FOR loop produced these topics:</strong></p>
<ul><?php echo $topic_list_1; ?></ul>
<?php else: ?>
<p style="color:red">GET_FIELD did not find any topics</p>
<?php endif; ?>
<!--or, let's try displaying those topics another way....-->
<?php
$vid_id = $post->ID;
$vid_custom = get_post_custom($vid_id);
?>
<?php if($vid_custom['topic'][0] != null): ?>
<?php
$topic_list_2 = '';
for($r=0;$r<$vid_custom['topic'][0];$r++):
$topic_title_2 = $vid_custom[topic_.$r._topic_title][0];
$topic_list_2 .= '<li>' . $topic_title_2 . '</li>';
endfor;
?>
<p><strong>The FOR loop produced these topics:</strong></p>
<ul><?php echo $topic_list_2; ?></ul>
<?php else: ?>
<p style="color:red">The FOR loop did not find any topics</p>
<?php endif; ?>
<br />
<?php endwhile; else: ?>
<p>Sorry, no posts or pages matched your criteria.</p>
<?php endif; ?>