我试图用高级自定义字段从相关帖子中加载一个中继器字段。
我有一个帖子,他有从另一个帖子类型加载帖子的关系。然后这个post_type有一个repeater_field。我试图加载我的相关帖子的这些repeater_field。它是另一个物体中的一个物体。
这是我的代码:
<?php
$posts = get_field('related_posts'); // this is a relation field
if( $posts ):
foreach( $posts as $p ):
?>
<section class="slider">
<?php
$quotes = get_field('slider_quotes'); // this is my repeater field
if( have_rows($quotes) ):
while ( have_rows($quotes) ) : the_row();
?>
<div><h2><?php echo get_sub_field('quote'); ?></h2></div>
<?php endwhile; else:
echo "Nothing yet";
endif; ?>
</section>
我已经试过了:
$frases = get_field('slider_quotes', $p->ID);
和
<?php echo get_sub_field('quotes', $p->ID); ?>
我什么也没得到。
谢谢!
完整代码
https://gist.github.com/pailoro/1541717925d9cd9622ba
如果'slider_quotes'是一个中继器字段,请尝试使用
<?php the_repeater_field('slider_quotes', $p->ID); ?>
请参阅链接以获取中继器字段的值