[Resolved] Static Share Buttons

Home Forums Support Static Share Buttons

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #349354
    Ronny

    Hello,
    to save load time I want to implement static share buttons on my website.
    On https://fastwp.de/430/ I found a nice Code. At the end I want to implement it with GP Hooks after the content of the pages.
    The Code I use is this.

    <a title="Bei Twitter empfehlen"> <?php echo urlencode(get_permalink($post->ID)); ?>" target="blank" rel="nofollow">Twitter</a> 
    <a title="Bei Facebook empfehlen">ID)); ?>&t=<?php echo rawurlencode(strip_tags(get_the_title())) ?>" target="blank" rel="nofollow">Facebook</a> 
    <a title="Bei Google+ empfehlen">ID)); ?>&title=<?php echo rawurlencode(strip_tags(get_the_title())) ?>" target="blank" rel="nofollow">Google+</a>

    Now with google and twitter it works fine but not with facebook. It opens a new tab, loads quickly and closes by itself. So nothing happens.
    Any Ideas? Thanks!

    #349464
    Tom
    Lead Developer
    Lead Developer

    Looks like your code got mashed up a bit while posting. If you can re-post it and be sure to highlight it and click the “code” button in the editor, that would be awesome.

    Using a plugin like this might be an easier solution: https://en-ca.wordpress.org/plugins/social-warfare/

    #349748
    Ronny
    <a title="Bei Twitter empfehlen" href="https://twitter.com/intent/tweet?source=webclient&text=<?php echo rawurlencode(strip_tags(get_the_title())) ?> <?php echo urlencode(get_permalink($post->ID)); ?>" target="blank" rel="nofollow">Twitter</a> | 
    <a title="Bei Facebook empfehlen" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode(get_permalink($post->ID)); ?>&t=<?php echo rawurlencode(strip_tags(get_the_title())) ?>" target="blank" rel="nofollow">Facebook</a> | 
    <a title="Bei Google+ empfehlen" href="https://plusone.google.com/_/+1/confirm?hl=de&url=<?php echo urlencode(get_permalink($post->ID)); ?>&title=<?php echo rawurlencode(strip_tags(get_the_title())) ?>" target="blank" rel="nofollow">Google+</a>

    Thats the Code.
    When I used Social Warfare the pageload time increased a lot… thats why I would prefer this method. Thanks.
    Just wondering why it does not work with facebook.

    #349815
    Tom
    Lead Developer
    Lead Developer

    Can you link me to a page where I can click one of the links?

    #350129
    Ronny
    #350255
    Tom
    Lead Developer
    Lead Developer

    Are you just adding that code into your page content? If so, it won’t work, as your content can’t render PHP.

    Something like that should be added into GP Hooks with Execute PHP checked.

    #350530
    Ronny

    I did try with gp hooks but its the same problem. Just wondering why google and twitter is working and facebook doesn’t.

    #350688
    Tom
    Lead Developer
    Lead Developer

    Neither are technically working, as the URL parameter is showing the PHP instead of the regular URL.

    Can you re-add them to GP Hooks and then show me?

    #351291
    Ronny

    Huh,
    don’t know why, but code is working now as it is supposed to be. And it really is a better solution to me than any social plug in. No more load time! Perfect one. Thanks for the fast support! GeneratePress is the best!

    #351430
    Tom
    Lead Developer
    Lead Developer
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.