Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Author’s Twitter and Facebook on the Profile Page

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display Author’s Twitter and Facebook on the Profile Page

By default WordPress allow to display author’s website, email, and a few other useless IM contacts, but it is missing important social media networks like Facebook, and Twitter. In this tutorial, we will show you how you can add author’s twitter, facebook, linkedin, or any other contact info on the profile page.

First thing you need to do is open your functions.php in your template folder and add the following codes:

function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//add Facebook
$contactmethods['facebook'] = 'Facebook';

return $contactmethods;

You can follow the methods and add any other field that you want. Once you add this function, user profile page in the admin panel will look like this:

Extend User Contact Info

Add the information there. Now you will need to display it in your template through author.php file. You should check out our tutorial on How to Add an Author Profile Page in WordPress and for further documentation also look at WordPress Codex page for Author Templating.

All you have to do is paste the following code in your template file:

<?php echo $curauth->twitter; ?>

You can change the name of the field to what you like. This way you can display it in your author.php file. You may modify it to your liking. For example use this as links and so on.

For example, if your value is simply “wpbeginner” in that field. Then you can paste this code in your author.php

<a href="<?php echo $curauth->twitter; ?>" target="_blank"><?php echo $curauth->twitter; ?></a>

If you have any questions feel free to write it in the comments, and we will answer them.

Note: This tutorial will work in WP 2.9+ thanks to Joost De Valk

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Touraj Aminfar says:

    Very goood and useful , thanks

  2. Abdelrahman Helmi says:

    How to make it visual icons??

  3. Iftekhar says:

    // Retrieve a custom field value
    $twitterHandle = get_the_author_meta(‘twitter’);

    I think this is much better code to retrieve custom field value.

  4. Vito says:

    I would like to apply this to the page of the publication of the post, and insert text tags for each post. similar to the custom fields but with this style is that possible?


  5. Aamir says:

    i am trying to include author google plus profile link in the template..
    i have successfully added custum field to add google plus link in user profile of evry author but not able to include in the template …
    i am using headway v3 ..
    as its not posiible to edit files like author.php in headway i tried inserting the code directly in postpages by creating a Custum Code block but GooglePLus; ?> does not work…
    please help..

  6. stephane.falzon says:

    I try but it did not work and now it’s good. I do not understand why, but thx.

  7. wpbeginner says:

    @stephane.falzon You can just add another line that says:$contactmethods[‘skype’] = ‘Skype’;

  8. stephane.falzon says:

    Hi, first of all really thanx for your help!

    Secondly, I try to add more field like ‘skype ID’ but I can’t add another.

    I had to change one of the two field.

    How I can do?


  9. erwin.pouli says:

    I add custom user field with this code:

    function my_custom_userfields( $contactmethods ) {

    $contactmethods[‘keyword_usr’] = ‘Keyword’;

    return $contactmethods;



    BUT it save the record with stripped html tag! how can i remove a strip tag filter?

    i want save record allow html code.

    For description profile i finded this code:

    remove_filter(‘pre_user_description’, ‘wp_filter_kses’);

    but for a new custom user field as ‘Keyword’, how can i solved?

    thx and congrat for your blog!


  10. thegooch says:

    What is the plugin’s name? I’d like to use it

  11. Shannon says:

    Here is the code I used to properly retrieve and post the authors Twitter account:

    I was having difficulty with the other method used in the post…ie, nothing was returned…the bit of code I included above did the trick.

    NOTE: I simply list the twitter account as “@WHATEVERYOURTWITTERNAMEIS” in the user/author setup page in WP…and then I incorporated the Twitter @anywhere hovercard to get an awesome effect. I use it in all of my Author Bio boxes for each post.

    • Shannon says:

      seems it filtered out the code:

      echo the_author_meta(‘twitter’);

      remember, this code needs to be enclosed in:

      just remove the spaces between .

      I don’t know how to post the code properly…

  12. richard says:

    where in the theme function page should i place this code??

  13. anika says:

    You can use plugin. why do you code by useself?

    • Jacky Liang says:

      There’s a Reason why you shouldn’t use Plugins.

      1. Vulnerabilities
      2. Incompatibility
      3. Slows your Blog Down

  14. Navjot Singh says:

    To display the output of any field, better option is to use the_author_meta(‘twitter’)

  15. Scott Lewis says:

    I added the code that you suggest at the end of my functions.php and it added the 2 lines into my profile. The only thing is that every time I update anything, I get the white page of death. If I go back to the previous page, the update was successful. It just won’t bring me directly back to the page I just updated. I had to take out the code because it was too much of a PITA.

    Any ideas what I did?

    • Editorial Staff says:

      Post your functions.php in the comment. That is the only way we could provide solution to this problem.

  16. rayne says:

    How do I add a dropdown instead of a text field?

    • Editorial Staff says:

      For that you would have to write a mini-plugin calling the function and telling it to add the dropdown box.

  17. Enk. says:

    A little more in details, how can we get it working like we only write ‘wpbeginner’ in fields and it links automatically ?

  18. Luke says:

    Thank you for this.

    Stupid question: What’s the code if you want to show only the info that’s displayed in user profile.

    For example, when I add these in the user profile and don’t enter data, it still shows the icon.

    • Editorial Staff says:

      You have to use a if then statement for that specific field in the database.

      • Nicole says:

        Could you elaborate on how to write the if then statement for this?

        • Editorial Staff says:

          If / Then statement are basics of PHP. This tutorial was added for developers. We would recommend looking at the PHP Tutorials site.

  19. John (Human3rror) says:

    very cool. i’m using it.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.