Support » Plugin: Jetpack by WordPress.com » sharing buttons on home page but not excerpts

  • Resolved Gretchen Louise

    (@gretchenlouise)


    I’d like to display the sharing buttons on the home page, but not on excerpts and archives. It seems like it should be a simple line of code to change this, but I can’t land on the right combination. Thanks for any help.

    (I would also like the sharing buttons to appear at the top of the post on the home page, but the top and bottom of other single posts/pages.)

    https://wordpress.org/plugins/jetpack/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Richard Archambault

    (@richardmtl)

    Happiness Engineer

    Hi Gretchen!

    Have a look at this:

    http://jetpack.me/2013/06/10/moving-sharing-icons/

    It should give you all you need for specifying on what templates and *where* on those templates yuou want the sharing code to appear, but if you need further help, let me know, that’s what I’m here for!

    Hi Richard,
    I’m actually not using templates, but adding the actions via functions.php

    Here’s what I have. It’s working everywhere except for the bottom of the post.


    //* Remove default Jetpack share locations
    function jptweak_remove_share() {
    remove_filter( 'the_content', 'sharing_display',19 );
    remove_filter( 'the_excerpt', 'sharing_display',19 );
    }
    add_action( 'loop_start', 'jptweak_remove_share' );

    //* Add Jetpack share buttons above content on home and single pages
    add_action( 'the_content', 'sp_share_buttons_above_post', 19 );

    function sp_share_buttons_above_post( $content = '' ) {
    if ( is_front_page() || is_single() ) {
    return sharing_display() . $content;
    } else {
    return $content;
    }
    }

    //* Add Jetpack below posts single pages
    function sp_share_buttons_below_post() {
    if ( is_single() ) {
    return sharing_display();
    }
    }

    add_action( 'genesis_entry_footer', 'sp_share_buttons_below_post', 19 );

    Plugin Contributor Richard Archambault

    (@richardmtl)

    Happiness Engineer

    Hey Gretchen,

    Could you post your site URL here, so I can have a look?

    If you want it to remain private, you can also contact us via this contact form:
    http://jetpack.me/contact-support/

    Make sure to include a link to this thread in your message.

    I ask, because it seems to me that genesis_entry_footer is for sites that are using (x)html4, so it’d be nice to see what your site is using.

    Plugin Contributor Brandon Kraft

    (@kraftbj)

    Howdy all,

    For anyone who finds this post seeking the same answer, instead of the last bit of code from the user’s example above, try this:

    function sp_share_buttons_below_post( $post_meta ) {
      if ( is_single() ) {
        return sharing_display().$post_meta;
      }
    }
    
    add_filter( 'genesis_post_meta', 'sp_share_buttons_below_post', 10);

    https://gist.github.com/kraftbj/9199140

    The latest Jetpack update seems to have broken this code’s ability to display the share buttons above the post. Has anyone else had this problem?

    Plugin Contributor Richard Archambault

    (@richardmtl)

    Happiness Engineer

    Hi Gretchen,

    Oh no! I don’t know what would have changed that would have caused this, however. I’ll ask Brandon if he can take a look and confirm this and possibly offer a solution. Thanks for letting me know.

    Thank you, Richard. Whatever the issue was, it seems to have resolved itself, so perhaps it was only on my site. Thank you for your quick response, though! Sorry to send you and Brandon after an apparent non-issue.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘sharing buttons on home page but not excerpts’ is closed to new replies.