Hello
I was wondering how to get acf values from an other pahe inside a repeater field on my main page.
Ex :
Page A = homepage
Repeater field = dvd_list with sub_field post object (setting on page content)
Page B = DVD sample
ACF filed = name
When I edit my A page, and pick the ‘DVD sample’ inside the repeater filed, I want to show on front page the name of the DVD
For the moment, I’m here with no success
<?php if( have_rows('dvd_list') ): ?>
<?php while( have_rows('dvd_list') ): the_row();
$dvdItem = get_sub_field('dvd_object');
$dvdName = get_field('dvd_name', $post->ID);
?>
<div><?php echo $dvdName; ?></div>
<?php endwhile; ?>
<?php endif; ?>
Any help would be great, thanks in advance
It sounds like Page A should have posts being listed (dvd_list) and then Page B should be outputting those posts or Post.
But to get a field from another page check out the answer I received from @hube2 here https://support.advancedcustomfields.com/forums/topic/output-fields-input-through-template-a-to-template-b/
Essentially the_field('field-name', page-id#);
ok thanks for your repply
Here is what I’ve done and got it worked without any fixed ID
<?php if( have_rows('dvd_list') ) : ?>
<?php while( have_rows('dvd_list') ): the_row();
$dvdItem = get_sub_field('dvd_object');
if ( $dvdItem) :
$dvdName= get_field_object('dvd_name', $dvdItem->ID);
?>
<div><?php echo $dvdName['value']; ?></div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>