Add More Social Network Handles To Your WordPress Author Profile
Posted by Nile | Posted in Tutorials | Posted on 05-08-2010 | 4 Comments
Tags: author profile, social network, theme filter
The authoer’s page by default only allows you to put just enough information up. For those who utilize their authors.php page, they can add more things like your Twitter and Facebook profile to their author profile and not have to even alter the core of their site. You can even add more than that.
This is done by adding and a simple function and filter to your theme’s functions.php file.
function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//add Facebook
$contactmethods['facebook'] = 'Facebook';
//add LinkedIn
$contactmethods['linkedin'] = 'LinkedIn';
return $contactmethods;
}
add_filter(‘user_contactmethods’,'my_new_contactmethods’,10,1);
If you want to add more, you can do that. For example, if I wanted to add in YouTube, I would put the following code in before the return $contactmethods line and after the last social network code listed. Example code:
//add Youtube
$contactmethods['youtube'] = 'Youtube';
In order to call these into your author profile page, you can put the following code. In the case of the code above for Twitter, LinkedIn, and Facebook:
Twitter:
<a href="http://twitter.com/<?php the_author_meta('twitter'); ?>">Twitter</a>
Facebook:
<a href="http://facebook.com/<?php the_author_meta('facebook'); ?>">Facebook</a>
LinkedIn:
<a href="http://linkedin.com/in/<?php the_author_meta('linkedin'); ?>">LinkedIn</a>
As a note, even though you can add as many social network accounts to your WordPress author profile, you should probably use the ones that are the most important and most relevant to your website’s visitors.
Sounds easy?
By the way, Joost de Valk is the one to give credit for the ability to add more to the user contact fields.








