Skip to content

Instantly share code, notes, and snippets.

@frankschrijvers
Last active April 21, 2016 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankschrijvers/46b64d6aaf1a5247f1d45455617ff18a to your computer and use it in GitHub Desktop.
Save frankschrijvers/46b64d6aaf1a5247f1d45455617ff18a to your computer and use it in GitHub Desktop.
How to create a custom author box in genesis
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Removes default Genesis Author Box, Adds a custom Author Box
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_after_entry', 'wps_theme_author_box', 8 );
function wps_theme_author_box() {
if ( is_singular('post') ) {
$author_avatar = get_avatar( get_the_author_meta( 'ID' ), 70 );
$author_name = get_the_author_meta( 'display_name' );
$author_desc = get_the_author_meta( 'description' );
$facebook = get_the_author_meta( 'facebook' );
$googleplus = get_the_author_meta( 'googleplus' );
$twitter = get_the_author_meta( 'twitter' );
$website = get_the_author_meta( 'url' );
echo '<section class="author-box">';
echo $author_avatar;
echo '<h4 class="author-box-title">About ' . $author_name . '</h4>';
echo '<div class="author-box-content" itemprop="description"><p>' . $author_desc . '</p></div>';
if ( $twitter || $facebook || $googleplus || $website ) {
echo '<div class="author-social-links">';
echo '<span>Follow me</span>';
}
if ( $facebook ) {
echo '<a class="fa fa-facebook author-link" href="' . $facebook . '" target="_blank"></a>';
}
if ( $googleplus ) {
echo '<a class="fa fa-google-plus author-link" href="' . $gplus . '" target="_blank"></a>';
}
if ( $twitter ) {
echo '<a class="fa fa-twitter author-link" href="https://twitter.com/' . $twitter . '" target="_blank"></a>';
}
if ( $website ) {
echo '<a class="fa fa-globe author-link" href="' . $website . '" target="_blank"></a>';
}
if ( $twitter || $facebook || $gplus || $website ) {
echo '</div>';
}
echo '</div>';
echo '</section>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment