Support » Plugins and Hacks » ShareThis: Free Sharing Buttons and Tools » Remove share-this from the_excerpt()?

Remove share-this from the_excerpt()?

  • How do I remove the share-this links from my blog index page?

    My blog index page is set to show the_excerpt(), instead of the_content().

    The problem is I end up with a page showing hundreds of sharethis links all over the place and it looks really stupid.

    I’d like to set it up so that the links are only on single post or single pages, not the archives. Can’t seem to find directions on this, and there seems to be no setting in the admin for this.


Viewing 15 replies - 1 through 15 (of 34 total)
  • Here is a great example of how bad it looks having share-this in the excerpt http://bit.ly/U8JLuQ

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    Hi Sir,
    If you want to add the sharethis buttons to post-pages only, you will have to add the sharethis code manually to your templates since this isn’t possible with the sharethis plugin.

    You can get the code (by selecting website platform is step 1 from here:http://sharethis.com/publishers/get-sharing-tools)
    Please note that you will have to modify the span tags as explained below.

    Sharethis script and span tags go on the page where you want the buttons to appear and they also determine what kind of button appears as well as what URL and title it shares. You will have to put these in your Single Post template (single.php) in order to add the buttons only to the post-pages.

    Depending upon the position of buttons on a page, you will have to decide the position of the code in th file single.php
    You can add:
    Sharethis script tags below the line:

    get_header(); ?>


    span tags below the line of code:

    <?php get_template_part( 'content', 'single' ); ?>

    Here is the basic span for just the ShareThis button:

    <span class="st_sharethis" st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>' displayText="ShareThis"></span>

    You can change the class of the span to determine the button that appears. For example class=”st_twitter” will make a twitter icon and class=”st_email_vcount” will make a email vertical counter button.

    You can read more about the different types of buttons here: http://help.sharethis.com/customization/customization-overview

    [ sharethissupport, all of your posts are being held in moderation and will need to be approved before users can see them. Please follow the rules and refrain using signatures in your reply posts. ]

    Ok, I couldn’t believe for a second that there wasn’t a way of doing it within the plugin so you made me go dig into the code and I found:

    if (get_option('st_add_to_content') != 'no' || get_option('st_add_to_page') != 'no') {
    	add_filter('the_content', 'st_add_widget');
    	// 2008-08-15 Excerpts don't play nice due to strip_tags().
    	add_filter('get_the_excerpt', 'st_remove_st_add_link',9);
    	add_filter('the_excerpt', 'st_add_widget');

    Would you please add a filter to the next vs. of sharethis so that we can simply use a filter to do this?

    Right now, all I have to do is comment out the last 2 add_filter…
    and it solves the problem.

    Now I’d rather not have to modify your plugin every time there is a new release, so if you would please follow WordPress coding standards and add in a filter hook there, then we can solve the problem with one line in our themes function file. It would be so easy to allow filters on both the_excerpt() and the_content() so that users could specify what they wanted.

    Heck even better:::::
    Why not hook it into the pre_get_posts() function on a per post-type basis, so we could then have ultimate control via filters?


    Thanks for such a nice suggestion.
    I’ll forward it to our team.

    [ sharethissupport, all of your posts are being held in moderation and will need to be approved before users can see them. Please follow the rules and refrain using signatures in your reply posts. ]

    I changed this back to not-resolved as the problem is still there in the latest vs.

    How about this idea for now:
    At the very least, apply a custom class to the <p> wrapper which surrounds the sharing icons. That way, for now, I can at least target the share buttons that I don’t want to display to hide them via css.

    While that’s a horribly tacky way, it is a quick 2 minute fix for you guys until you decide to do it right.

    You said you forwarded the suggestion….
    Did they give you an e.t.a. on the fix?

    Every single site I have built using this plugin has this problem, and it’s rather annoying. The rest of the plugin is awesome, so lets just get this last issue solved and move on.

    Hello sir,
    We have noted the point and may add this option to the sharethis plugin in future.
    Right now we don’t have plans to add it to the immediate release.
    Also,I don’t know ETA on this.
    I will let you know once the product team confirms about it to me.
    The Sharethis Support

    LOL… I did the exact same as Anointed… hunt around in their crummy code only to find no hook to fix their lack of basic options. Then coming here and finding this thread.

    Adding an option to display/not display on excerpts requires about 5 lines of code… it took longer to write this email than it’d take to fix it.

    @anointed and @jon Brown

    Put this in your themes Function.php file

    remove_filter( 'get_the_excerpt', 'st_remove_st_add_link', 9 );
    remove_filter( 'the_excerpt', 'st_add_widget' );

    The plugin should have checkboxes to remove from:

    Pretty dumb.

    I made this to remove it from single pages.

    if (!is_page_template('page.php')) {
    remove_filter( 'the_content', 'st_remove_st_add_link', 9 );
    remove_filter( 'the_content', 'st_add_widget' );

    Hope this helps you guys out!

    I tried share-this with Simplepress Forum … it added share-this to ever user comment .. any idea how to get rid of that, seems like the same issue discussed here – trying to limit where it posts. Thanks!

    I am a bit of a novice – what happens when I insert
    your proposed code into function.php?
    remove_filter( ‘get_the_excerpt’, ‘st_remove_st_add_link’, 9 );
    remove_filter( ‘the_excerpt’, ‘st_add_widget’ );

    Does it give me options somewhere? Can’t see any change…


    That code removes it from showing up in your list of blog articles. The three line code I provided removes it from single pages (not posts/articles). Your homepage, contact page, about us page etc. but no, the code does not add options. It just removes it.

    UPDATE SHARETHIS: As of now there is an option under the share this settings.

    In your admin dashboard, Sidebar > SETTINGS > SHARETHIS and about half way down the page you will see two options.

    Automatically add share this to your posts/pages.

    I leave yes to posts on so people can share your blog items.

    And then say no to pages because its pretty ugly in my opinion.

    Any questions, feel free to ask.

    thanks cmccrone – that’s clear. What I really want to do is remove the buttons from the excerpts, wherever they appear.

    Ok, I just showed my gf how to do this. She is learning all about blogs at the moment. She has a Love Poems For Her Blog..

    Here is the code she used there to remove the buttons from the excerpts.

    remove_filter( 'get_the_excerpt', 'st_remove_st_add_link', 9 );
    remove_filter( 'the_excerpt', 'st_add_widget' );

    Add that code to your function.php file
    LOCATION: http://lovepoemsforher.com/wp-content/themes/theme-name/function.php

    You can edit it using an FTP tool or logging into wordpress. In the sidebar go to Appearance > Editor > Theme Functions (functions.php) and add the code


    thx cmccrone
    yes, just added code. Settings on plugin to show on pages and blogs. But Still showing on excerpts. http://hertscollegeofhypnosisandnlp.co.uk/
    I am using a custom theme from woothemes… And this is the theme that I edited. Any ideas?

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘Remove share-this from the_excerpt()?’ is closed to new replies.
Skip to toolbar