WordPress.org

Ready to get started?Download WordPress

Forums

ShareThis: Share Buttons and Social Analytics
[Plugin: ShareThis: Share Buttons and Sharing Analytics] Add share this to homepage? (2 posts)

  1. Anointed
    Member
    Posted 1 year ago #

    Plugin is working perfectly, but I would like to add the buttons to my site homepage as well.

    Is there a shortcode or something that I can manually insert into my homepage template?

    If I set my blog to have a static homepage and blog page, then it works, but my theme has other problems doing that so it's out of the question. I am unfortunately stuck using the standard 'posts on homepage' reading setting.

    Because the homepage technically does not have a post per say, there is nothing for the share this buttons output to 'hook' to, thus no output on my homepage.

    http://wordpress.org/extend/plugins/share-this/

  2. sharethissupport
    Member
    Posted 1 year ago #

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

    Hi,
    Do you want to add the buttons to all the pages of your blog?
    If yes, the sharethis plugin settings(http://YOUR WP BLOG/wp-admin/options-general.php?page=sharethis.php)

    as:
    Automatically add ShareThis to your posts?* Yes

    Automatically add ShareThis to your pages?* Yes

    should work fine.
    But, if you want to add the buttons on some pages only, then please note that displaying sharethis conditionally is not possible with the automatic installation however this can still be done by setting the plugin to not automatically place the buttons and then adding the span tags manually to your templates.

    These 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 'script tags' in your Main index template(index.php) and 'span tags ' in Single Post template(single.php).

    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.

    However, adding code in index.php and single.php will not display sharethis buttons on the blog page but will show buttons whenever an individual post is opened.
    If you wish to display sharethis buttons on the blog page ,you will have to put 'span tags' in (loop.php).

    In loop.php,
    1. put span tags just above the line "<div class="entry-utility">" to display buttons at the end of each post on the blog page.

    <span  class='st_sharethis' ></span>
       <div class="entry-utility">

    2. to display buttons at the beginning of each post on the blog page,put span tags just below the lines

    <h2 class="entry-title"><a>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
       <div class="entry-meta">
        <?php twentyten_posted_on(); ?>
       </div><!-- .entry-meta -->
    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>

    For Example:You will have to put a sharethis <span> tags in a conditional block with condition:

    if (<?php the_permalink(); ?> is equal to 'Title of page to which you wish to add sharethis buttons')
    {
            //Sharethis <span> tags
    }

    Hope this helps.

    Thanks and Regards,
    [ 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. ]

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags