I've added some extra $curauth fields to the user profile page via ths method:
function change_contactmethod( $contactmethods ) {
$contactmethods['twitter'] = 'Twitter URL';
// more $contactmethods go here
return $contactmethods;
}
add_filter('user_contactmethods','change_contactmethod',10,1);
And they are displayed this way on the author.php template, which only displays the link if it is entered in te user profile:
<?php echo $curauth->twitter; ?>
But what I need to do is determine if the curauth field exists before display, as I want to turn the twitter URL into a linked image. Calling $curauth->twitter; as above with a linked image still displays the image if no link is entered in the users profile.
This is what I'm trying with no luck:
<?php $my_post_meta = get_post_meta($post->ID, 'twitter', true);
if ( ! empty ( $my_post_meta ) )
echo '<a href=" '.$my_post_meta.' "><img src="<?php bloginfo(\'template_url\'); ?>/images/twitter.png"></a>'; ?>
Update 12/23/11 - This now works:
<?php if ( !empty( $curauth->twitter ) ) { echo '<a href=" ' . $curauth->twitter . '"><img src="' . get_bloginfo('template_url') . '/images/twitter.png"></a>'; } ?>