<?php /* * Loop through post objects (assuming this is a multi-select field) ( don't setup postdata ) * Using this method, the $post object is never changed so all functions need a seccond parameter of the post ID in question. */ $post_objects = get_field('YOUR_CUSTOM_FIELD'); if( $post_objects ): ?> <ul> <?php foreach( $post_objects as $post_object): ?> <li> <a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a> </li> <?php endforeach; ?> </ul> <?php endif; ?>
Very useful!
Can I ask how did you register the post object in function.php?
Thank you in advance