Social sharing is one of the best ways to bring more traffic to your website.
Jetpack is one of the most popular plugins which also includes social sharing buttons.
The only problem is, the social buttons by default, are displayed after the content.
This tutorials contains the code for Genesis users and other themes which enables you to reposition the buttons.
Display Share Buttons Before Post Content Using Code
This code will work with any theme.
It displays the buttons both before and after your content.
Paste this code at the end of your child themes functions.php file to display your Jetpack social sharing buttons before your posts content.
Display Share Buttons Before Post in Genesis
Works in Genesis only and only displays the icons before the single post content.
add_action( 'genesis_entry_header', 'reposition_jetpack', 5 );
function reposition_jetpack() {
if ( is_singular( 'post' ) && function_exists( 'sharing_display' ) ) {
sharing_display( '', true );
}
}
Remove is_singular( 'post' ) &&
to also show the icons on archives like this:
add_action( 'genesis_entry_header', 'reposition_jetpack', 5 );
function reposition_jetpack() {
if ( function_exists( 'sharing_display' ) ) {
sharing_display( '', true );
}
}
Move Share Buttons After Post in Genesis
This PHP code will actually reposition your Jetpack share buttons after the content. Although this is the default position, this hook position in Genesis is after the after post content hook as you can see in this image.
You can edit this code to display Jetpack buttons anywhere in your theme.
Change Sharing Button Position
All you need to do in if you want to add Jetpack share buttons in another theme location is to change the hook in the code above. Here’s a list of all Genesis hooks as well as a visual hook map which shows you the position each hook executes in your theme.
Note: The above code uses the old XHTML loop hooks so you will need to change the hook if running HTML 5.
If you find this tip helpful, please share it.
Leave a Reply
You must be logged in to post a comment.