Skip to content

Instantly share code, notes, and snippets.

@tjhole
Created December 1, 2015 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjhole/6162dfeb6708882f1187 to your computer and use it in GitHub Desktop.
Save tjhole/6162dfeb6708882f1187 to your computer and use it in GitHub Desktop.
<?php
$post_object = get_field('post_object');
if( $post_object ):
// override $post
$post = $post_object;
setup_postdata( $post );
?>
<div>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<span>Post Object Custom Field: <?php the_field('field_name'); ?></span>
</div>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment