• Resolved andersbalari

    (@andersbalari)


    I wondered how to place Jetpack’s/Sharedaddy’s sharing functionality where I like and only where I like.

    The automatic placement is triggered by two filter adds within the code of the plugin (within ‘sharing-service.php’).

    In order to override this in a specific loop it is necessary to remove these filters right before the content tag. Code then should look like this:

    <?php remove_filter( 'the_content', 'sharing_display', 19 ); ?>
      <?php remove_filter( 'the_excerpt', 'sharing_display', 19 ); ?>
      <?php the_content(); ?>

    Then just add the tag <?php echo sharing_display(); ?> wherever you like, but of course within the loop.

    I found a solution suggesting to remove the two adds from the plugin code. But my solution has two big advantages:

    • First, it survives plugin updates. Caveat: The respective code stays unchanged => this should be checked after each update.
    • Secondly, you still have the possibility of automatic sharing placement in each loop you do not modify this way.

    Cheers

    Anders

Viewing 6 replies - 16 through 21 (of 21 total)
  • Clifford Paulick

    (@cliffpaulick)

    In my experience, I have to check the box for the CPT I’m trying to add this to, but then if I add the PHP echo, it shows up twice instead of just once.
    Do I need the box checked for the CPT? I’d prefer not and then only include Jetpack Sharing only where I explicitly include it via PHP or shortcode.
    What am I missing?
    Thanks for your help.

    Clifford Paulick

    (@cliffpaulick)

    Update: I’m not using it in the loop. Is there any way to include it outside of the loop? I’m just using the CPT for wp-admin input and using a custom single page display code (no loop). It’s a very custom display and I want to add the sharing buttons right where I want them.
    Thank you.

    @andersbalari do I need to remove the filter for every loop or can I just add the remove_filter lines once to my functions.php?

    Thread Starter andersbalari

    (@andersbalari)

    In my experience, I have to check the box for the CPT I’m trying to add this to, but then if I add the PHP echo, it shows up twice instead of just once.

    What do you mean with CPT? I’m not familiar with this abbreviation.

    @andersbalari do I need to remove the filter for every loop or can I just add the remove_filter lines once to my functions.php?

    It should work to remove the filters within your functions.php – just give it a try and let us know the result ;-).

    CPT = “Custom Post Type”

    Sorry it wasn’t clear.

    I havent had any luck with this working on my blog either. No matter what i do, it still shows up twice. Ive tried changing the priority to higher, but no difference. =/

Viewing 6 replies - 16 through 21 (of 21 total)
  • The topic ‘Custom Placement of Jetpack's/Sharedaddy's Sharing’ is closed to new replies.