My Related Template

 In

//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 ‘‘.get_the_title( $id ).’‘;
//get the value for some_field in related post and echo it
$someField = get_post_meta( $id, ‘some_field’, true );
echo $someField;
} //end of foreach
} //endif ! empty ( $related )
?>

Recent Posts

Start typing and press Enter to search