Simple Share Buttons Adder
[resolved] Buttons on homepage posts (12 posts)

  1. freshcreate
    Posted 3 years ago #

    Is possible to use the shortcode in the post-loop file (homepage)?

    When I put the code in the post-loop, the icons do appear correctly beside every post, but it wants to share the homepage link instead of the post page link.

    Any tip is appreciated


  2. David Neal
    Plugin Author

    Posted 3 years ago #


    Have you edited a file in order to display the buttons? The shortcode will by default extract the current page URL, but you can force it to share a specific URL if you wish, like so:

    [ssba url="http://www.simplesharebuttons.com" title="Simple Share Buttons"]

    Both a title and url must be specified. You could use a couple of WordPress functions to specify each of these, here's an excerpt used in the plugin:

    $urlCurrentPage = get_permalink($post->ID);
    $strPageTitle = get_the_title($post->ID);

    You should however be able to simply achieve this by checking the 'Homepage' option within the admin panel, but the above may be useful if you are trying to achieve something different.

    Hope it helps!


  3. freshcreate
    Posted 3 years ago #

    Hi thanks for you response. Still trying to fix it, I'm not a coding pro so please bear with me.

    I tried checking the 'homepage' option but it didn't do anything.

    I'll be a little more specific, my homepage contains links to all my posts, here is a snippet of the relevant code in the loop (I think the top php section is relevant).

    						global $wpdb;
    						$sql="select * from $wppost where ID='$post->ID'";
    						$query =mysql_query($sql);
    							 $post_title  = $res['post_title'];
    					<h1><a href="<?php the_permalink(); ?>"><?php echo strip_tags($post_title);  ?></a></h1>

    Well I tried this but it didn't work:
    <div style="margin-top:-5px;"><?php echo do_shortcode('[ssba url=<?php the_permalink(); ?> title="Share"]'); ?></div>

    Thanks again

  4. David Neal
    Plugin Author

    Posted 3 years ago #

    Some themes aren't configured quite as WordPress requests I believe, so unfortunately it doesn't always work straight away.

    You'll need to wrap the URL attribute in double quotes for it to work, have a go with the below:

    <div style="margin-top:-5px;"><?php echo do_shortcode('[ssba url="' . the_permalink() . '" title="' . $post_title . '"]'); ?></div>

    Note that I've also used your post_title variable for the title. I've stripped out the second <?php tag for you to. A good attempt, well done for having a stab at it.

    Saying that, hopefully I've got it right myself, I'd like to have tested it first!

    Hope it works for you, let me know how you get on!

  5. freshcreate
    Posted 2 years ago #

    Appreciate the advice, but it hasn't seemed to have done the trick...

    Here's what is appearing: text of the post's url, followed by the buttons, which are incorrectly trying to share the homepage url instead of the post url, as before.

  6. David Neal
    Plugin Author

    Posted 2 years ago #

    Hey, sorry to hear that hasn't worked for you.

    Would you be happy to share the file that you are editing so I can take a look?

    Sharing via http://ge.tt/ is a good way.



  7. freshcreate
    Posted 2 years ago #

    Sure, here is the file - http://www.mediafire.com/?1akyb7k0bnv3iny

    Let me know if there's any other info I can provide

  8. mudfooted
    Posted 2 years ago #

    I am desparately trying to get the ssba to work on my own location in the theme on the homepage but nothing works. Your suggestion above:
    <?php echo do_shortcode('[ssba url="' . the_permalink() . '" title="' . $post_title . '"]'); ?>
    just prints the url and leaves the ssba the same.. I tried many other things but nothing works. Shouldn't this be very easy? What would the code be if you would say create a separate shortcode for the homepage that links to the permalink of the post instead of the url of the whole page? I really hope you can help me with this.

  9. Jeff1601
    Posted 2 years ago #

    Try this one:
    <?php echo do_shortcode('[ssba url="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '"]'); ?>

    I'm not a programmer but for me it works

  10. David Neal
    Plugin Author

    Posted 2 years ago #

    Thanks for helping out there Jeff :)

  11. Jeff1601
    Posted 2 years ago #

    Thank you for this great Plugin :)!

  12. mudfooted
    Posted 2 years ago #

    I am working on my website again and although the code above suggested by Jeff1601 works in the sense that it shows the buttons, there is a weird problem with the share count of google+. Namely on the frontpage/archive pages etc which show multiple posts on one page the google+ share count is either "0" or "958". It is always either of these two. On single pages the google share count works properly. Can you please help me solve this as I have no idea. Or perhaps you have a different code to show the buttons on posts on the frontpage and the code suggested by Jeff1601? Thanks a lo.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Share Buttons Adder
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.