Hi there, im using the selection field “User Field” as a custom field on my author.php pages.
What I want to achieve is to connect/link my different users with this field that I call “reports_to”.
If I do this:
<?php echo '<pre>';
print_r( get_field('report_to', $curauth) );
echo '</pre>'; ?>
It returns everything from ID, first name, last name etc.
But, I want to return display name with link to author_posts_url like this below.
echo
'<a href="'
. get_author_posts_url( $author->ID, $author->user_nicename ).
'">'
.$author->display_name.
'</a>';
How :)?
Hi @dillehal
Hmm… You could try this:
$author = get_field('report_to', $curauth);
echo
'<a href="'
. get_author_posts_url( $author['ID'] ).
'">'
.get_author_meta('display_name', $author['ID']).
'</a>';
For more info, check out the following links:
https://codex.wordpress.org/Function_Reference/get_the_author_meta
https://codex.wordpress.org/Function_Reference/get_author_posts_url
Works!
Except it is get_the_author_meta not get_author_meta 🙂
Thanks!