Graphene Themes Forum

Graphene Themes Forum

Community support for Graphene themes

  • Home
  • Register
    • Reset password
  • Contact Us

Home › Forums › Graphene WordPress theme › Support

Social Share (AddThis) buttons required at end of all posts

  • gmbcorp

    August 12, 2011 at 9:54 am #1544

    Hello.

    I currently use a plugin to display social sharing buttons at the end of each post, but I’d much rather use the built-in feature of Graphene.

    This is fine if I want the buttons at the top of the post, but if I want the buttons at the bottom they will only appear on single-page posts. At first I thought it was a bug, but after looking at the code I see this is done on purpose.

    I tried moving the appropriate code out of the “if” statement, and while it worked in getting the buttons on every post, it placed the button after other post-footer plugins.

    How do I get the social share buttons to appear at the end of every post, immediately after the text/content?

    Any help would be much appreciated.

    wowcast

    August 17, 2011 at 9:25 am #16191

    I need this for my http://www.wowcast.de Website as well. Hope some1 knows the answer for it!

    sincerly

    Admin

    Syahir Hakim

    August 18, 2011 at 12:35 am #16192

    Create a functions.php file (if you don’t already have one) in your child theme, and add this code:

    <?php
    function graphene_custom_addthis_placement(){
    graphene_addthis( get_the_ID() );
    }
    add_action( 'graphene_after_post_content', 'graphene_custom_addthis_placement' );
    ?>

    markimedes

    August 20, 2011 at 7:37 am #16193

    Thanks for the code Syahir.

    It does work, however I then noticed that you’ll get two instances of the social sharing buttons on a single-post page. LOL.

    I haven’t tried it, but I would assume this is easily worked around by doing something like this:

    <?php
    function graphene_custom_addthis_placement(){
    if ( is_single_post() ) :
    else :
    graphene_addthis( get_the_ID() );
    endif;
    }
    add_action( 'graphene_after_post_content', 'graphene_custom_addthis_placement' );
    ?>

    However, I still couldn’t get the buttons above my other end-of-post plugin. In the end, I did it all manually in my child’s functions.php. Fortunately my other end-of-post plugin has an option to use code, and then because I disagree with AddThis forcing a “via @addthis” string to the Tweet button, I did the buttons myself, too.

    For those that may want to do something like that, here’s the code I ended up doing (I’m a beginner, so apologies to you demon-coders who could do this with half the lines 🙂

    function my_buttons(){
    if (is_page()) :
    else : ?>
    <br>
    <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
    <a href="http://twitter.com/share" class="twitter-share-button"
    data-url="<?php the_permalink(); ?>"
    data-via="your_twitter_handle"
    data-text="<?php the_title(); ?>"
    data-count="horizontal">Tweet</a>
    <g:plusone href="<?php the_permalink(); ?>" size="medium"></g:plusone>
    <script type="text/javascript">
    (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    })();
    </script><br><h3>You may also like...</h3>
    <?php get_related_posts_thumbnails();
    endif;
    }
    add_action( 'graphene_after_post_content', 'my_buttons' );

    So here I’ve got a Tweet button for the specific post, and G+1 button that does the same. Then after the two buttons I put in a line break before calling the other plugin (a related posts plugin).

    Doing it this way allows me to control the order of the plugins, and also do little things like adding an empty line between the end of the post and the sharing buttons.

    You can see how it looks here.

    Hope this has been helpful to someone 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

  • You must be logged in to reply to this topic.
Log In

Account

Log In
Register Lost Password

Search Forums

Priority Support

This free Support Forum relies on contributions from our support staffs and fellow Graphene themes users. While we endeavour to provide adequate and timely support, due to its voluntary nature responses are not guaranteed and may be delayed.

If you require urgent assistance, you may like to consider our Priority Support option.

Get Priority Support

Forums

  • Graphene WordPress theme
  • Graphene Mobile
  • Graphene Mobile Neo
  • Franz Josef

Recent Topics

  • Force language
    4 months ago
  • PHP Warning “display_name” as boolean in comments.php
    5 months ago
  • Page Numbers can’t be seen
    5 months ago
  • Cannot download Graphene-Shortcodes-Plugin
    5 months ago
  • php Fatal errors and warnings filling logs
    5 months ago

Made with by Graphene Themes.