Skip to content

Instantly share code, notes, and snippets.

Created September 23, 2014 16:33
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 anonymous/e33f90ee987700c19545 to your computer and use it in GitHub Desktop.
Save anonymous/e33f90ee987700c19545 to your computer and use it in GitHub Desktop.
Relationships with Pods Templates
<?php
//get the value for the relationship field
$related = $obj->field( 'game_platform' );
//loop through related field, creating links to their own pages
//only if there is anything to loop through
if ( ! empty( $related ) ) {
foreach ( $related as $rel ) {
//get id for related post and put in ID
//for advanced content types use $id = $rel[ 'id' ];
$id = $rel[ 'ID' ];
//show the related post name as link
echo '<a href="'.get_permalink($id).'">'.get_the_title( $id ).'</a>';
//get the value for some_field in related post and echo it
$someField = get_post_meta( $id, 'post_title', true );
echo $someField;
} //end of foreach
} //endif ! empty (
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment