Move Jetpack Sharing Buttons Above the Content
Shows Jetpack's sharing buttons at the top of posts instead of the bottom, and keeps the Like button at the bottom where readers expect it.
Opens WPIDE on
Code
add_action( 'loop_start', function () {
if ( ! function_exists( 'sharing_display' ) ) {
return;
}
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
} );
add_filter( 'the_content', function ( $content ) {
if ( ! function_exists( 'sharing_display' ) || ! is_singular() || ! in_the_loop() || ! is_main_query() ) {
return $content;
}
return sharing_display( '', false ) . $content;
}, 8 );
Notes
Also removes the buttons from excerpts so they do not repeat on archive pages.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.