Hello,
I’m wondering how to us the drop down menu for the Page Link field to return the Post ID associated with it’s page?
So, depending upon what page the user selects, it would return the Post ID for that page.
Thanks
You might have to use the Post Object field instead and then maybe do something like:
<?php
$post_objects = get_field('post_objects');
if( $post_objects ): ?>
<?php foreach( $post_objects as $post_object): ?>
$postID = $post_object->ID
<a href="<?php echo get_permalink($postID); ?>">
<?php echo get_the_title($postID); ?>
</a>
<?php endforeach; ?>
<?php endif; ?>
Hi @SQD
Yes, you will need to use the post_object field instead of page_link.
Thanks
E
Thanks Jamie and Elliot. This answered my question
For anyone else interested in passing field data between pages while using a drop down menu to connect the pages together, here’s one way to do it:
Get field data from another page via drop down menu:
Page A (master page)
Page B (sub-page): Linked to Page A via drop-down menu
Create a post object field on Page B’s ACF called ‘select_page’
In order for Page B to access field data from Page A:
Add something like this in Page B’s php code:
<? $pages = get_field('select_page');
get_field('content_from_page_A', $pages->ID);
?>