Created
September 23, 2014 16:33
-
-
Save anonymous/e33f90ee987700c19545 to your computer and use it in GitHub Desktop.
Relationships with Pods Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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