繁体   English   中英

ACF:从关系字段中加载转发器字段

[英]ACF: load repeater field from a relationship field

我试图从具有高级自定义字段的相关帖子中加载转发器字段。

我有一个与谁有关系可以从另一个post_type加载帖子的帖子。 然后,此post_type具有Repeater_field。 我尝试加载相关文章的这些repeater_fields。 它是另一个对象内的一个对象。

这是我的代码:

<?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); ?>

参考链接以获取转发器字段的值

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM