Skip to content

Instantly share code, notes, and snippets.

@jarred
Created December 12, 2011 19:48
Show Gist options
  • Select an option

  • Save jarred/1468780 to your computer and use it in GitHub Desktop.

Select an option

Save jarred/1468780 to your computer and use it in GitHub Desktop.
<?php
$field = get_field('related-post');
if (preg_match("/page_id=(.+)/", $field, $matches)) {
$page = get_page($matches[1]);
echo 'Related page: ' . $page->post_title;
} elseif (preg_match("/p=(.+)/", $field, $matches)) {
$post = get_post($matches[1]);
echo 'Related post: ' . $post->post_title;
} else {
echo 'No related page or post';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment