Wordpress Snippets

Add Jetpack Sharing Buttons Above Post Content

If you are self hosting WordPress on your server then you are missing out tons of features available specifically to wordpress.com users. To narrow this gap down, WordPress team has developed Jetpack plugin for self hosted blogs so they can also take benefits of these features without hosting their website on wordpress.com’s restrictive environment. Since Jetpack solves tons of problems in one single plugin and packs with many great features to supercharge your website, it is one of the most popular plugin in WordPress plugin respiratory. Today we will discuss Share Buttons feature in Jetpack.

The Jetpack sharing buttons in the plugin are the easiest way to share content and connect with social networking websites. By default WordPress adds the Jetpack sharing buttons to the bottom of your post content. This could be an issue for some who want to display Jetpack sharing buttons above post content. But the problem is that the plugin does not provide any option or straight forward way to change the default location of sharing buttons. Following is a simple solution for you, if you want to move these Jetpack sharing buttons above post content and post title.

If you would like to display the Jetpack sharing buttons at the top and bottom of your entry content, just paste this code snippet into your theme’s functions.php file.

// add jetpack share buttons above post content
function wcs_move_jetpack_share_buttons_above_content( $content="" ) {
    if ( function_exists( 'sharing_display' ) ) {
        return sharing_display() . $content;
    } else {
        return $content;
    }
}

remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );

add_filter( 'the_content', 'wcs_move_jetpack_share_buttons_above_content', 19 );
add_filter( 'the_excerpt', 'wcs_move_jetpack_share_buttons_above_content', 19 );

source

Hire Us. Or just say Hi!
Need a job? Apply to get one.