Custom links for WordPress author profiles

November 21, 2014

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.


// 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 ) {

$authorsociallink['rss_url'] = 'RSS URL'; $authorsociallink['google_profile'] = 'Google Profile URL'; $authorsociallink['twitter_profile'] = 'Twitter Profile URL'; $authorsociallink['facebook_profile'] = 'Facebook Profile URL'; $authorsociallink['linkedin_profile'] = 'Linkedin Profile URL';

return $authorsociallink; }

addfilter( 'usercontactmethods', 'customauthorlinks', 10, 1); ?>;

retrieving custom data : Full Code Snippet:

Within you desired template add the following:

<div class="profile__meta">
    <h3 class="profile-name"><?php the_author(); ?></h3>
&lt;?php if ( get_the_author_meta('description') ) : ?&gt;
&lt;div class="profile-desc"&gt;&lt;?php the_author_meta('description'); ?&gt;&lt;/div&gt;
&lt;?php endif; ?&gt;

&lt;?php if ( get_the_author_meta('user_url') ) : ?&gt;
&lt;a href="&lt;?php esc_url( the_author_meta('user_url')); ?&gt;" class="profile-url"&gt;&lt;?php the_author_meta('user_url'); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;

&lt;?php if ( get_the_author_meta('rss_url') ) : ?&gt;
&lt;a href="&lt;?php esc_url( the_author_meta('rss_url')); ?&gt;" class="rss-url"&gt;&lt;?php echo get_the_author_meta( 'rss_url' ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;

&lt;?php if ( get_the_author_meta('twitter_profile') ) : ?&gt;
&lt;a href="&lt;?php esc_url( the_author_meta('twitter_profile')); ?&gt;" class="twitter-url"&gt;&lt;?php echo get_the_author_meta( 'twitter_profile' ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;

&lt;?php if ( get_the_author_meta('google_profile') ) : ?&gt;
&lt;a href="&lt;?php esc_url( the_author_meta('google_profile')); ?&gt;" class="google-url"&gt;&lt;?php echo get_the_author_meta( 'google_profile' ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;

&lt;?php if ( get_the_author_meta('facebook_profile') ) : ?&gt;
&lt;a href="&lt;?php esc_url( the_author_meta('facebook_profile')); ?&gt;" class="facebook-url"&gt;&lt;?php echo get_the_author_meta( 'facebook_profile' ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;

&lt;?php if ( get_the_author_meta('linkedin_profile') ) : ?&gt;
&lt;a href="&lt;?php esc_url( the_author_meta('linkedin_profile')); ?&gt;" class="linkedin-url"&gt;&lt;?php echo get_the_author_meta( 'linkedin_profile' ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;


More information about author meta can be found on the WordPress Codex.

Join over 30,000 developers & designers who get the best news and articles delivered right to their inbox each week.