The author’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.
sam says
Nice Post,
No doubt in that social media sites are play very big role in each and every blog post/site and you mentioned very well how we can make our blog post/site more powerful with the help of these tools.
David Cornick says
Nile, This is brilliant, I was totally unaware this could be done.As a “newbie” I appreciate any help I can get
sai says
wow really a great wordpress trick to add more custom fields.keep sharing more tricks for wordpress 🙂
Karen says
This is a great option, though I have added Facebook, I am having issues with Google+, added it to the user page, but after adding the Google+ number and clicking update profile, the number disappears and I just can’t seem to get it to work!
sai says
i’m too agree with you mate 🙂
Mike The Lawyer says
Looks great – when I pasted it into the functions.php the fields showed. When I entered text into the profile area and tried to update the user, I received a “page not found” error afterward. I’m using WP 3.3 and wonder if that might have something to do with it.
AnujSharma says
This is cool but can it work with other theme or can you get tricks to use for other themes?
I will be expecting your reply…
Nile says
Yes, this works with other themes. You just put the code in your functions.php file of your theme.
Matt says
Nice, I’ll try these codes in my site. Hopefully there will be no problem.