Support » Plugin: Jetpack - WP Security, Backup, Speed, & Growth » Cannot move share buttons

  • Hi,
    I tried to use the instructions here to move my Jetpack social sharing buttons.

    Adding them in the position I wanted worked, but they aren’t being removed from their default location.

    This is the code I added to functions.php that isn’t removing them properly:

    function jptweak_remove_share() {
        remove_filter('the_content', 'sharing_display', 19);
        remove_filter('the_excerpt', 'sharing_display', 19);
        if (class_exists('Jetpack_Likes')) {
            remove_filter('the_content', array(Jetpack_Likes::init(), 'post_likes'), 30, 1);
        }
    }
    add_action('loop_start', 'jptweak_remove_share');

    I noticed the instructions are from 2013 – has something changed?

    Thanks in advance for your help

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    The code should still work, but your theme or another plugin may already be customizing Jetpack and inserting the buttons in a custom location.

    Could you try to switch to one of the default themes for a few minutes, and let me know if it helps?

    Thread Starter tamarakorr

    (@tamarakorr)

    I switched to the Twenty Seventeen theme, and the sharing buttons of course appear at the end of a post just once, since that theme isn’t customised to remove them.

    I’m trying to customise a very simple theme I wrote myself, to reposition the sharing buttons slightly. I can see the jptweak_remove_share() function is being called properly when I view a single post, by adding an error_log() message to it. It’s just not actually removing the buttons.

    I guess the next step is to look at the JetPack code and see whether ‘sharing_display’ and the priority values are correct. I hoped somebody else might know since I’m obviously not familiar with that code.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    I switched to the Twenty Seventeen theme, and the sharing buttons of course appear at the end of a post just once, since that theme isn’t customised to remove them.

    Excellent! I would now recommend that you add the snippet to the Twenty Seventeen theme.

    • If it works, you’ll know that the problem is linked to your theme and how it implements the_content.
    • If it still doesn’t work, you’ll know that there is a conflict between Jetpack and another one of the plugins on your site. Deactivating them one at a time will then help you figure out which one.

    Let me know what you find!

    I guess the next step is to look at the JetPack code and see whether ‘sharing_display’ and the priority values are correct.

    The priority values we used in the tutorial are correct, and the snippet in that tutorial is correct; I just tested it again just to be sure.

    You can check the plugin’s code here:
    https://github.com/Automattic/jetpack/blob/4.6/modules/sharedaddy/sharing-service.php#L797-L798

    Thread Starter tamarakorr

    (@tamarakorr)

    The snippet does remove the sharing buttons from posts in the Twenty Seventeen theme. When I take out the snippet, they reappear. So that’s all good. It means the problem is my theme, somehow.

    My theme just calls the_content(). It doesn’t do anything tricky with it, and doesn’t try to add sharing buttons. Is there anything else that could trigger the sharing buttons to print? (Besides the_excerpt() of course, which I don’t use in single posts.) I glanced through the JetPack code and it didn’t look like anything else can call sharing_display(). I wouldn’t think it would matter, but the test site is in JetPack safe mode.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Could you look for references to sharing_display() in your theme, to make sure the buttons aren’t added manually somewhere else?

    Thread Starter tamarakorr

    (@tamarakorr)

    There are no other references to sharing_display() anywhere in the theme. I haven’t included any code related to JetPack in the theme, except as indicated in the instructions in my original post.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    Could you share if there are any other functions hooking into the_content in your theme

    Having a similar problem, been using <?php if ( function_exists( ‘sharing_display’ ) ) remove_filter( ‘the_excerpt’, ‘sharing_display’, 19 ); ?> to remove sharing for years so i can move it to the right place.

    No longer works for me….what changed in the recent jetpack update?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    @thelanj We didn’t make any changes to that function in the recent Jetpack update. Could you let us know what theme you’re using? Do you maybe happen to use the same theme as @tamarakorr?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Cannot move share buttons’ is closed to new replies.