Last active
August 29, 2015 14:02
-
-
Save axeldevo/ba55bd7b516a5209b890 to your computer and use it in GitHub Desktop.
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( 'company_staff' ); | |
//loop through related field, creating links to their own pages | |
//only if there is anything to loop through | |
if ( ! empty( $related ) && is_array($related) ) { | |
$output = array(); | |
foreach ( $related as $rel ) { | |
//get id for related user and put in id | |
//get name for related user and put in name | |
$user = get_userdata( $rel[ 'ID' ] ); | |
$name = $rel[ 'display_name' ]; | |
$permalink = $rel[ 'user_nicename' ]; | |
//show the related post name as link | |
$output[] = '<a href="'. 'http://www.website.com/' . 'profile/' . $permalink .'">' . pods_image( $user->user_avatar, 'thumbnail') . '</a><p> ' . $name . ' </p>'; | |
} //end of foreach | |
echo implode(' ',$output); | |
} //endif ! empty ( $related ) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment