Let’s pull lots of stuff about the Authors on the author.php page.
First we’ll see what author we are showing…
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );
Then we can do lots of cool stuff.
Echo authors first name:
echo $author->first_name;
More parameters can be found here.
Show Advanced Custom Fields assigned to the Users:
$youField = get_field('your_custom_field', 'user_'. $author->ID ); echo $youField;
Here’s another example of ACF Author info showing the Birthdate custom field:
$date = DateTime::createFromFormat('Ymd', get_field('birthday', 'user_'. $author->ID )); $birthdate = $date->format('M j'); echo $birthdate;
Finally, how to show a custom taxonomy associated with a User.
$terms = get_the_terms( $author->ID , 'profession' ); foreach ( $terms as $term ) { $term_link = get_term_link( $term, 'profession' ); if( is_wp_error( $term_link ) ) continue; echo '' . $term->name . ''; }
This pulls the terms from the Custom Taxonomy, “profession” that is associated with the user. This example expands on a demo created by this smart guy on how to create Custom Taxonomies for Users. (note that he is missing his first add action in his example. you can figure out how to fix it in his comments section.)