Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Socialising your Author Box in Genesis WordPress Theme

July 10, 2014 7 Comments

The Author Box in WordPress is sometimes overlooked and underused and it doesn’t display all the contact information entered such as Social Media contacts, this guide goes through turning it on, editing the contact meta info, using a new AuthorBox with the new contact info and using icon fonts to display those social media accounts.

Turning on the Author box for any Genesis HTML5 theme can be done with a filter in functions.php or via the Users Profile in the WP Dashboard.

Filter Method

add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );

WP Dashboard Method

The above filter when added to your child themes function.php file will add the Author Box to every post.

genesis-author-box-enable-on-posts

Or in WP Dashboard User Profile

genesis-author-box biographical info

The information displayed in the Author Box will be the Gravatar of the User, name and any Biographical Info entered in the user profile.

genesis-author-box

Author Box displayed after post content

 

Altering Contact Methods

Staying in the User Profile, there are a number of contact methods, such as Social Media accounts, these can be removed or new ones added. I can’t speak for the rest of the world but AIM, YAhoo IM and Jabber are things that happened many many moons ago.

genesis-author-box-contact-methods

These contact methods can be controlled with the user_contactmethods filter.

function 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', 'modify_user_contact_methods' );

So here I am removing AIM, Yahoo and Jabber by using unset and adding contact fields for Pinterest and LinkedIn by declaring them as user contact meta. – reference

genesis-author-box-contact-methods-added

The result is a profile more up to date.

Outputting the new contact methods in a New AuthorBox

First thing to do is to remove the current author box and display our new author box, in function.php add;

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_after_entry', 'themeprefix_alt_author_box' );

So we are adding a new function for our alternative authorbox and removing the existing one and conditionally applying the new one only on single posts.

function themeprefix_alt_author_box() {
	if( is_single() ) {
		echo 	"<div class=\"author-box\">" . get_avatar( get_the_author_meta( 'ID' ), '70' ) . 
				"<div class=\"about-author\"><h4>About " . get_the_author()  . "</h4><p>" . get_the_author_meta( 'description' ) . 
				"<div class=\"contact-links\"><a href=\"" . get_author_posts_url( get_the_author_meta( 'ID' )) . "\">View all posts by " . get_the_author() . "</a></div></div></div>";
	}

}

remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_after_entry', 'themeprefix_alt_author_box' );

The above code will get the authorbox to the state it was previously in the older author box, with the author gravatar, name, description but also generating a link to all posts by the same author. The gravatar square pixel size is the argument passed in after the .get_avatar function, in the above example set to 70px.

The next thing to do is bring in our new contact methods which is done with the get_the_author_meta function with the field parameter passed in along side it, for example  get_the_author_meta( ‘linkedin’ )

function themeprefix_alt_author_box() {
if( is_single() ) {

echo 	"<div class=\"author-box\">" . get_avatar( get_the_author_meta( 'ID' ), '70' ) . 
		"<div class=\"about-author\"><h4>About " . get_the_author()  . "</h4><p>" . get_the_author_meta( 'description' ) . 
		"<div class=\"all-posts\"><a href=\"" . get_author_posts_url( get_the_author_meta( 'ID' )) . "\">View all posts by " . get_the_author() . "</a></div></div>
		<ul class=\"social-links\">";
		
		if ( get_the_author_meta( 'linkedin' ) != '' ) {
			echo "<li><a href=\"". get_the_author_meta( 'linkedin' ) . "\">LinkedIN</a></li>";
		}
		if ( get_the_author_meta( 'facebook' ) != '' ) {
			echo "<li><a href=\"". get_the_author_meta( 'facebook' ) . "\">Facebook</a></li>";
		}
		if ( get_the_author_meta( 'twitter' ) != '' ) {
			echo "<li><a href=\"https://twitter.com/". get_the_author_meta( 'twitter' ) . "\">Twitter</a></li>";
		}
		if ( get_the_author_meta( 'googleplus' ) != '' ) {
			echo "<li><a href=\"". get_the_author_meta( 'googleplus' ) . "\">Google+</a></li>";
		}
		if ( get_the_author_meta( 'pinterest' ) != '' ) {
			echo "<li><a href=\"". get_the_author_meta( 'pinterest' ) . "\">Pinterest</a></li>";
		}
		if ( get_the_author_meta( 'user_email' ) != '' ) {
			echo "<li><a href=\"mailto:". get_the_author_meta( 'user_email' ) . "\">Email</a></li>";
		}
		if ( get_the_author_meta( 'user_url' ) != '' ) {
			echo "<li><a href=\"". get_the_author_meta( 'user_url' ) . "\">Website</a></li>";
		}							

echo "</ul></div>";
	}
} 

remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_after_entry', 'themeprefix_alt_author_box' );

The code for each user contact method first checks to see if the value is empty and it it isn’t echos out the data, a couple of methods need some tweaks to the HTML, both the email and Twitter values.

genesis-author-box-social-media-lists

Giving Us a Social Media List

All that would be needed now is some CSS styles applied to the list items using the unordered list style of .social-links.

Outputting the new contact methods in a New AuthorBox with FontAwesome Icons

Lets do it with some icons instead from the brilliant fontawesome…

 //Load Fontawesome
function themeprefix_fontawesome_styles() {
	wp_register_style ( 'fontawesome' , '//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css', '' , '4.1.0', 'all' );
	wp_enqueue_style( 'fontawesome' );
}

add_action( 'wp_enqueue_scripts', 'themeprefix_fontawesome_styles' ); 


function themeprefix_alt_author_box() {
	if( is_single() ) {
		echo 	"<div class=\"author-box\">" . get_avatar( get_the_author_meta( 'ID' ), '70' ) . 
				"<div class=\"about-author\"><h4>About " . get_the_author()  . "</h4><p>" . get_the_author_meta( 'description' ) . 
				"</div><ul class=\"social-links\">";
				
				if ( get_the_author_meta( 'linkedin' ) != '' ) {
					echo "<li><a href=\"". get_the_author_meta( 'linkedin' ) . "\"><i class=\"fa fa-linkedin\"></i></a></li>";
				}
				if ( get_the_author_meta( 'facebook' ) != '' ) {
					echo "<li><a href=\"". get_the_author_meta( 'facebook' ) . "\"><i class=\"fa fa-facebook\"></i></a></li>";
				}
				if ( get_the_author_meta( 'twitter' ) != '' ) {
					echo "<li><a href=\"https://twitter.com/". get_the_author_meta( 'twitter' ) . "\"><i class=\"fa fa-twitter\"></i></a></li>";
				}
				if ( get_the_author_meta( 'googleplus' ) != '' ) {
					echo "<li><a href=\"". get_the_author_meta( 'googleplus' ) . "\"><i class=\"fa fa-google-plus\"></i></a></li>";
				}
				if ( get_the_author_meta( 'pinterest' ) != '' ) {
					echo "<li><a href=\"". get_the_author_meta( 'pinterest' ) . "\"><i class=\"fa fa-pinterest\"></i></a></li>";
				}
				if ( get_the_author_meta( 'user_email' ) != '' ) {
					echo "<li><a href=\"mailto:". get_the_author_meta( 'user_email' ) . "\"><i class=\"fa fa-envelope-o\"></i></a></li>";
				}
				if ( get_the_author_meta( 'user_url' ) != '' ) {
					echo "<li><a href=\"". get_the_author_meta( 'user_url' ) . "\"><i class=\"fa fa-laptop\"></i> </a></li>";
				}
								
		echo "</ul></div>";
	}

} 

remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
add_action( 'genesis_after_entry', 'themeprefix_alt_author_box' );

And add in some CSS…

.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;   
}

Giving Us…

genesis-author-box-social-media-socialised

 

Full Gist

On the page example – little bit further down… icon-arrow-circle-o-down

Cats: WebDev, WordPress

About Neil Gee

Well this is the spot where all the good stuff is written about me, I have a cat called Merlin, he is a mystical creature.

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Discuss

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • Matter update may finally take the tedium out of setting up your smart home
  • Cue: Apple will add AI search in mobile Safari, challenging Google
  • Apps like Kindle are already taking advantage of court-mandated iOS App Store changes
  • Spotify seizes the day after Apple is forced to allow external payments
  • Apple and Meta furious at EU over fines totaling €700 million

RSS mac surfer

  • Tot is new text editor for Mac, iPhone, and iPad focused on constraints and ease of use
  • TiPbITS: Google Drive Sorting Can Hide New Documents
  • How to take a screenshot on a MacBook Pro
  • How To Create Simple Animation With Mac Keynote
  • Last Week on My Mac: Virus pandemics

Donate

Copyright © 2025· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2025 · gee on Genesis Framework · WordPress · Log in