Skip to content

Instantly share code, notes, and snippets.

@sudipbd
Created December 28, 2016 06:00
Show Gist options
  • Save sudipbd/99cece00e970da5c4aa0b74f06d47903 to your computer and use it in GitHub Desktop.
Save sudipbd/99cece00e970da5c4aa0b74f06d47903 to your computer and use it in GitHub Desktop.
WordPress Author Bio
//fb and tw for author
function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//add Facebook
$contactmethods['facebook'] = 'Facebook';
return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);
<div class="author_bio">
<?php echo nl2br(get_the_author_meta('description')); ?>
<div class="author_social">
<?php
$twitter = get_the_author_meta('twitter', $author_id);
$facebook = get_the_author_meta('facebook', $author_id);
if(!empty($twitter)) {
echo '<a title="Follow me on Twitter" href="'.$twitter.'"><i class="fa fa-facebook"></i>';
}
if(!empty($facebook)) {
echo '<a title="Follow me on Facebook" href="'.$facebook.'"><i class="fa fa-twitter"></i>';
}
?>
</div>
</div>
.author_social {margin: 20px 0;}
.author_info {background-color: #ececec;}
.author_info img {float: left; margin-right: 20px;}
.author_social i {
padding: 9px;
margin-right: 16px;
width: 40px;
text-align: center;
height: 30px;
color: #fff;
}
.author_social i.fa.fa-facebook {background-color: #3B5998;}
.author_social i.fa.fa-twitter {background-color: #0084B4;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment