The following snippet when placed within WordPress’ functions.php
will allow authors to add custom links to their profile and display for each author bio.
functions.php
<?php
// Add to your theme's functions.php
//
// You can access this data anywhere in your
// theme by using get_the_author_meta()
function custom_author_links( $author_social_link ) {
$author_social_link['rss_url'] = 'RSS URL';
$author_social_link['google_profile'] = 'Google Profile URL';
$author_social_link['twitter_profile'] = 'Twitter Profile URL';
$author_social_link['facebook_profile'] = 'Facebook Profile URL';
$author_social_link['linkedin_profile'] = 'Linkedin Profile URL';
return $author_social_link;
}
add_filter( 'user_contactmethods', 'custom_author_links', 10, 1);
?>;
retrieving custom data : Full Code Snippet: http://www.codeshare.io/zAVZu
Within you desired template add the following:
<div class="profile__meta">
<h3 class="profile-name"><?php the_author(); ?></h3>
<?php if ( get_the_author_meta('description') ) : ?>
<div class="profile-desc"><?php the_author_meta('description'); ?></div>
<?php endif; ?>
<?php if ( get_the_author_meta('user_url') ) : ?>
<a href="<?php esc_url( the_author_meta('user_url')); ?>" class="profile-url"><?php the_author_meta('user_url'); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta('rss_url') ) : ?>
<a href="<?php esc_url( the_author_meta('rss_url')); ?>" class="rss-url"><?php echo get_the_author_meta( 'rss_url' ); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta('twitter_profile') ) : ?>
<a href="<?php esc_url( the_author_meta('twitter_profile')); ?>" class="twitter-url"><?php echo get_the_author_meta( 'twitter_profile' ); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta('google_profile') ) : ?>
<a href="<?php esc_url( the_author_meta('google_profile')); ?>" class="google-url"><?php echo get_the_author_meta( 'google_profile' ); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta('facebook_profile') ) : ?>
<a href="<?php esc_url( the_author_meta('facebook_profile')); ?>" class="facebook-url"><?php echo get_the_author_meta( 'facebook_profile' ); ?></a>
<?php endif; ?>
<?php if ( get_the_author_meta('linkedin_profile') ) : ?>
<a href="<?php esc_url( the_author_meta('linkedin_profile')); ?>" class="linkedin-url"><?php echo get_the_author_meta( 'linkedin_profile' ); ?></a>
<?php endif; ?>
</div>
More information about author meta can be found on the WordPress Codex.
Want to become a better web developer?
Join over 25,000 other developer & designers who get awesome links to the best news and articles each week delivered directly to their inbox.
Awesome Post. i have gained much knowledge from your post
Hi, very interesting post. 😉
I just have a question: How can I display the Bio of users, customers, editors, subscribers, etc. ?
Hey Dino,
Within your template you will need to add the following:
<?php $authorDesc = the_author_meta('description'); echo $authorDesc; ?>
Awesome article I was looking for this solution , Thanks