简体   繁体   中英

ACF: load repeater field from a relationship field

I trying to load a repeater field from related posts with advanced custom field.

I have a post who has a relationship to load posts from another post_type. Then this post_type has a repeater_field. I tried to load these repeater_fields of my related posts. Its a object inside another object.

Here is my code:

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

I already tried:

$frases = get_field('slider_quotes', $p->ID);

and

<?php echo get_sub_field('quotes', $p->ID); ?>

And I got nothing.

Thanks!

FULL CODE

https://gist.github.com/pailoro/1541717925d9cd9622ba

If 'slider_quotes' is an repeater field, try to get with

<?php the_repeater_field('slider_quotes', $p->ID); ?>

refer the link to get values of repeater field

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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