Skip to content

Instantly share code, notes, and snippets.

@axeldevo
Last active August 29, 2015 14:02
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 axeldevo/ba55bd7b516a5209b890 to your computer and use it in GitHub Desktop.
Save axeldevo/ba55bd7b516a5209b890 to your computer and use it in GitHub Desktop.
<?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