Hello I am using advanced custom fields and I am trying to pull data from multiple pages and display it on another
I set up a relationship field called “data”, and then on page X where the relationship field is displayed I have chosen page Y where I want to pull the data from
<?php if( get_field('data') ): ?>
<?php the_field('special_offer'); ?> <!--// get content from page Y -->
<?php endif; ?>
I can’t get this to work though and Im presuming the above is wrong, does anyone know how I could do this please?
Hopefully I have explained it clearly
Cheers
*This seems to be the solution, although having troubles pulling the_content etc
<?php $offers = get_field('data'); ?>
<?php if( $offers ): ?>
<ul>
<?php foreach( $offers as $location ): ?>
<li>
<a href="<?php echo get_permalink( $location->ID ); ?>">
<?php echo get_the_title( $location->ID ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
You have to include the page ID in the code:
From the documentation:
http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-another-page/