If you want use a custom field from an author in your WordPress template, try this snippet.
This would be especially useful if you're creating an "author box" for a blog post and want to show custom fields. You might include social media links, author
This is written specifically to be used with Advanced Custom Fields (using the get_field helper function), but you can use it for fields created with Meta Box or any other custom field plugin. Just swap
get_field
for whatever helper function your plugin uses. (For example, the function is rwmb_meta
for Meta Box.)<?php /** * Returns the value of supplied user field. * @param string $field_name Name of the custom field created using ACF. * @return string Value of user field. function get_author_custom_field( $field_name ) { $author_id = get_the_author_meta( 'ID' ); return get_field( $field_name, 'user_' . $author_id ); } */ function get_author_custom_field( $field_name ) { $author_id = get_the_author_meta( 'ID' ); return get_field( $field_name, 'user_' . $author_id ); } ?>