Skip to content

Instantly share code, notes, and snippets.

@remkus
Forked from neilgee/aauthorbox.php
Last active August 29, 2015 14:26
Show Gist options
  • Save remkus/9193be5c687965dfdff5 to your computer and use it in GitHub Desktop.
Save remkus/9193be5c687965dfdff5 to your computer and use it in GitHub Desktop.
Genesis WordPress Customised Author Box
<?php
//do not copy the opening php tag above
/**
* Changing the AuthorBox in WordPress
*
* @package Changing the AuthorBox in WordPress
* @author Neil Gee
* @link http://wpbeaches.com/author-box-genesis/
* @copyright (c) 2014, Neil Gee
*/
//Change Default Method Contacts in User Profile
function themeprefix_modify_user_contact_methods( $user_contact ){
/* Add user contact methods */
$user_contact['pinterest'] = __( 'Pinterest URL' );
$user_contact['linkedin'] = __( 'LinkedIn URL' );
/* Remove user contact methods */
unset($user_contact['aim']);
unset($user_contact['jabber']);
unset($user_contact['yim']);
return $user_contact;
}
add_filter( 'user_contactmethods', 'themeprefix_modify_user_contact_methods' );
//Load Fontawesome
function themeprefix_fontawesome_styles() {
wp_register_style( 'fontawesome' , '//netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css', '' , '4.4.0', 'all' );
wp_enqueue_style( 'fontawesome' );
}
add_action( 'wp_enqueue_scripts', 'themeprefix_fontawesome_styles' );
//Create New Author Box
function themeprefix_alt_author_box() {
if( is_single( '' ) ) {
//author box code goes here
?>
<div class="author-box"><?php echo get_avatar( get_the_author_meta( 'ID' ), '70' ); ?>
<div class="about-author"><h4>About <?php echo get_the_author(); ?></h4><p><?php echo get_the_author_meta( 'description' ); ?>
</div>
<div class="all-posts"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' )); ?>">View all posts by <?php echo get_the_author(); ?></a></div>
<ul class="social-links">
<?php if ( get_the_author_meta( 'facebook' ) != '' ): ?>
<li><a href="<?php echo get_the_author_meta( 'facebook' ); ?>"><i class="fa fa-facebook"></i></a></li>
<?php endif; ?>
<?php if ( get_the_author_meta( 'twitter' ) != '' ): ?>
<li><a href="https://twitter.com/<?php echo get_the_author_meta( 'twitter' ); ?>"><i class="fa fa-twitter"></i></a></li>
<?php endif; ?>
<?php if ( get_the_author_meta( 'googleplus' ) != '' ): ?>
<li><a href="<?php echo get_the_author_meta( 'googleplus' ); ?>"><i class="fa fa-google-plus"></i></a></li>
<?php endif; ?>
<?php if ( get_the_author_meta( 'github' ) != '' ): ?>
<li><a href="<?php echo get_the_author_meta( 'github' ); ?>"><i class="fa fa-github"></i></a></li>
<?php endif; ?>
<?php if ( get_the_author_meta( 'user_email' ) != '' ): ?>
<li><a href="mailto:<?php echo get_the_author_meta( 'user_email' ); ?>"><i class="fa fa-envelope-o"></i></a></li>
<?php endif; ?>
<?php if ( get_the_author_meta( 'user_url' ) != '' ): ?>
<li><a href="<?php echo get_the_author_meta( 'user_url' ); ?>"><i class="fa fa-laptop"></i> </a></li>
<?php endif; ?>
</ul>
</div>
<?php
}
}
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_entry_footer', 'themeprefix_alt_author_box', 10 );
/* For FontAwesome Icon Stylin */
.social-links {
overflow:auto;
margin-top:10px;
}
.social-links li {
list-style-type: none;
float: left;
}
.social-links a {
border-bottom: none;
}
.social-links i {
background: #205D7A;
color: #fff;
width: 40px;
height: 40px;
border-radius: 20px;
font-size: 25px;
text-align: center;
margin-right: 10px;
padding-top: 15%;
transition-property: opacity;
transition-delay: 0.3s;
transition-duration: .5s;
}
.social-links i:hover {
opacity:.7;
}
<?php
function themeprefix_alt_author_box() {
if( is_single() ) {
//author box code goes here
}
}
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_entry_footer', 'themeprefix_alt_author_box' ); //change hook for position
<?php
function themeprefix_alt_author_box() {
if( is_single() ) {
?>
<div class="author-box"><?php echo get_avatar( get_the_author_meta( 'ID' ), '70' ); ?>
<div class="about-author">
<h4>About <?php echo get_the_author(); ?></h4>
<p><?php echo get_the_author_meta( 'description' ); ?>
</div>
<div class="contact-links"><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' )); ?>">View all posts by <?php echo get_the_author(); ?></a>
</div>
</div>
<?php }
}
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_after_entry', 'themeprefix_alt_author_box' );
<?php
function themeprefix_modify_user_contact_methods( $user_contact ){
/* Add user contact methods */
$user_contact['pinterest'] = __( 'Pinterest URL' );
$user_contact['linkedin'] = __( 'LinkedIn URL' );
/* Remove user contact methods */
unset($user_contact['aim']);
unset($user_contact['jabber']);
unset($user_contact['yim']);
return $user_contact;
}
add_filter( 'user_contactmethods', 'themeprefix_modify_user_contact_methods' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment