Add Facebook, Twitter, LinkedIn, and GooglePlus to WordPress User Profile

Social media has becoming popular in the late 5 years. I’m not sure why wordpress still don’t allow us to enter Facebook, Twitter, LinkedIn and Google+ profiles for users by default.

Just in case you’re really need to add this to each user’s profile. And this is not jus for facebook and other social media links, this is generally¬†adding additional contact information for wordpress user. Here are the helpful codes to do it.

You can add each social network fields just like how aim, yim, and jabber. Paste this code in functions.php which is usually located at the template folder directory.

function extra_contact_info($contactmethods) {

unset($contactmethods['aim']);

unset($contactmethods['yim']);

unset($contactmethods['jabber']);

$contactmethods['facebook'] = 'Facebook';

$contactmethods['twitter'] = 'Twitter';

$contactmethods['linkedin'] = 'LinkedIn';

$contactmethods['googleplus'] = 'Google+';

return $contactmethods;

}

add_filter('user_contactmethods', 'extra_contact_info');

Remove jabber, yim, and aim from wordpress user profile

The script above allow us to add new fields (facebook, twitter, etc.) and remove old field. If you want to keep them just remove the line with unset command.

Add Facebook, Google+, Linkedin profile in your blog post

Now that you have added a new contact information for the user, you’ll need to call it to be displayed on your page, for example in a blog post inside a box something like “about the author.”

Make sure to place the code inside a loop. Same place where <?php the_title(); ?> and <?php the_content(); ?> is located.

<p>This author's facebook page is <?php the_author_meta('facebook'); ?></p>

Same process will go for other additional profile fields.

There are times that you want to add this information outside the loop. In this case, use the code below:

<p>Follow me on twitter at <?php the_author_meta('twitter',25); ?></p>

Where 25 is the user’s ID.