Top Ad unit 728 × 90

Display Author’s Twitter and Facebook Information on their Profile Page


WordPress has fields for fields for author contacts, but it has not been updated in ages. So by default you do not have an ability to add author’s twitter or facebook. With this hack you can add this information on their profile page.
First open your functions.php and paste the following code:
01<?php
02function my_new_contactmethods( $contactmethods ) {
03// Add Twitter
04$contactmethods['twitter'] = 'Twitter';
05//add Facebook
06$contactmethods['facebook'] = 'Facebook';
07
08return $contactmethods;
09}
10add_filter('user_contactmethods','my_new_contactmethods',10,1);
11?>
The above code will add two extra fields on your user-edit page named twitter and Facebook. You can display the code with the following code in your author.php file.
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:
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:
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 Codexpage for Author Templating.
All you have to do is paste the following code in your template file:
1<?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
1<a href="http://twitter.com/<?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
Display Author’s Twitter and Facebook Information on their Profile Page Reviewed by Unknown on 2:49 AM Rating: 5

No comments:

All Rights Reserved by Boca Raton Real Estate © 2014 - 2015
Powered By Blogger, Designed by Sweetheme

Contact Form

Name

Email *

Message *

Powered by Blogger.