Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am working on a site and it is possible that the site will have a number of pages which feature links to the client's social networking sites (Twitter, Facebook, LinkedIn...).

Now I know that the URLs to their profile shouldn't change too often, but they would like the option to update the URLs if they ever needed to.

My question is what the best method would be to allow my client to simply visit one page in the Admin area where they can copy and paste the new URLs into the fields for each social media site?

I thought about using Custom fields, but I guess there must be a way I can create a small widget that just allows me to echo whatever has been placed in the fields for each social media site. That way I can just echo that particular widget in the 'href' of the social media button and I can use it anywhere I want in my theme files.

Problem is, I don't delve much into custom widgets yet and I am not sure whether 1) it's the best way to achieve this and 2) Whether you can create a widget that simply allows you to echo whatever has been place in that field (almost just like a custom field).

Any clarification would be greatly appreciated.

Thanks,

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The best way is on the user profile page using the contact methods extension:

add_filter( 'user_contactmethods', 'more_contactmethods' );
function more_contactmethods( $contactmethods ) {
    $contactmethods['twitter'] = 'Twitter username';
    $contactmethods['facebook'] = 'Facebook URL';
    return $contactmethods;
}

This adds fields to the user profile page for those social networks. You can have as many as you like, then you can use that data in a widget or via a template tag in the following way:

$twitter = get_usermeta( $user_id, 'twitter' );

Actually writing the widget or template tag is a separate question though.

share|improve this answer
    
Adding this to my functions.php doesn't seem to change anything. Am I right in thinking that I should be able to see the fields in the Users > Your Profile page? –  remi90 Oct 31 '11 at 12:04
    
Silly me, it works, I was editing a different functions.php file I have open in my editor. Thank you sancho :) –  remi90 Oct 31 '11 at 12:13
    
@remi90 ah! No problem –  sanchothefat Oct 31 '11 at 12:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.