Site logo

Archived topic

Static Share Buttons

9 replies · Started by Ronny on July 14, 2017

Viewing posts 1–10 of 10

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!

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/

<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.

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

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.

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

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?

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!

Glad you got it working! :)

This archived topic is closed to new replies.