Support

Account

Home Forums General Issues Get ACF values from an other ACF page fileds

Solved

Get ACF values from an other ACF page fileds

  • 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; ?>
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.