• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Genesis Snippets

A reference for Genesis theme developers

  • Home
  • Archives
  • Search Genesis Snippets

jetpack

Reposition Jetpack sharing links

June 13, 2013 By David Wang

Love it or hate it, the Jetpack plugin offers one of the better options for enabling sharing links on your WordPress site. Unfortunately in Genesis the links are displayed in between the content and post meta. Here’s how to reposition the sharing links.

Place this code into functions.php

/** Custom positioning of Jetpack buttons */

// Remove the 'the_content' filter callback added by sharedaddy 
// to prevent the sharing links from being appended to the posts content.

add_action( 'init', 'custom_init', 11 );
function custom_init(){
  
	// if sharing_display() function does not exist, return
	if( ! function_exists( 'sharing_display' ) )
		return;
	
	// remove the callback sharing_display() for the 
	// 'the_content' and 'the_excerpt' filters.
	remove_filter( 'the_content', 'sharing_display', 19 );
	remove_filter( 'the_excerpt', 'sharing_display', 19 );
	
}

// Display sharedaddy buttons

add_action( 'genesis_before_post_content', 'child_do_sharedaddy' );
function child_do_sharedaddy(){
    
	global $post;
	
	// if sharing_display() does not exist, return
	if( ! function_exists( 'sharing_display' ) )
		return;
	
	// get the sharedaddy links html
	$sharedaddy_links = sharing_display();
	
	// if sharing_display() does not return anything, return
	if( empty( $sharedaddy_links ) )
		return;
	
	// create a template for the sharedaddy box content
	$template = '<div class="sharedaddy-box">%s</div>';
	
	// display the sharedaddy links within it's own box
	$content = sprintf( $template, $sharedaddy_links );
	
	// apply a filter for future adjustments
	echo apply_filters( 'sharedaddy_box_content', $content, $template, $sharedaddy_links );
	
}

In the above code we are displaying the buttons at the top of the post at the genesis_before_post_content hook. Reposition the buttons by hooking them on any of the other Genesis hooks.

Credit: Ryan Meier. The above code borrows liberally from his tutorial – Moving Jetpack Sharedaddy links outside the content with Genesis

See also: The Jetpack team has a blog post about this too – Moving Sharing Icons

Last modified: 27 June 2013

Filed Under: Genesis Tagged With: jetpack, plugin integration

Primary Sidebar

Brought to you by ClickWP
Buy the Genesis Theme Framework

Who’s behind this?

Hi! I'm David and I'm a big Genesis fan. I've been using it in all my projects and have found it to be super powerful.

I started this site to keep track of all the snippets that I've been using in my projects and so that it's easy for me to find them again instead of digging through my old project files.

Help support this site by buying Genesis with our affiliate links. Thanks!

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 354 other subscribers

Browse Snippets

branding cache comments css custom post type doctype entry footer entry header favicon featured image genesis_custom_loop images internet explorer jetpack loop media menu metabox minify navigation oembed page layouts performance plugin integration post thumbnail shortcode sidebars theme options widget areas widgets WooCommerce WordPress
Everything you need to support your online business
Take WordPress further with the Genesis framework

Copyright © 2025 · Genesis Sample On Genesis Framework · WordPress · Log in