WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've used this code to show custom fields if they're filled in a post using Custom Field Suite Plugin

<?php if($cfs->get('whatliked')){?>
<?php echo $cfs->get('whatliked'); ?>
<?php   }?>

Now I need to have the same check for some custom profile fields I've added through functions.php

/* BEGIN Custom User Contact Info */
 function extra_contact_info($contactmethods) {
     $contactmethods['facebook'] = 'Facebook';
     $contactmethods['twitter'] = 'Twitter';
     $contactmethods['google+'] = 'Google+';
     $contactmethods['linkedin'] = 'LinkedIn';
     return $contactmethods;
 add_filter('user_contactmethods', 'extra_contact_info');
 /* END Custom User Contact Info */

What is the code I need to add to my author.php to check if the facebook field has been filled and if "yes" then show and if "no" then hide...

P.s. Is there a way to post the code with linebreaks already in???

share|improve this question
Indent the line four spaces and you get a code block. (There is a Javascript tool-- look for {}) See: wordpress.stackexchange.com/editing-help – s_ha_dum Mar 15 '13 at 21:57

On an "author" page you can get a lot of the information you need with get_queried_object and additional information with get_user_meta. What you want (sounds like) should be in that second chunk of information.That is...

$author = $wp_query->get_queried_object();
$ameta = get_user_meta($author->ID);

var_dump($author,$ameta); // debugging

if(!empty($ameta['facebook'])) {
  var_dump($ameta['yim']); // debugging
// and so one for each contact method that you want to show

I am sure that is not how you want the information formatted but that should get you going.

share|improve this answer

Your Answer


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.