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
Are there any more code needed? Because it doesn’t seem to work for me, but still thanks for the information.
AA++ Post