- This topic has 9 replies, 2 voices, and was last updated 6 years, 9 months ago by Tom.
-
AuthorPosts
-
July 14, 2017 at 7:35 am #349354Ronny
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!July 14, 2017 at 10:27 am #349464TomLead DeveloperLead DeveloperLooks 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/
July 15, 2017 at 4:01 am #349748Ronny<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.July 15, 2017 at 9:37 am #349815TomLead DeveloperLead DeveloperCan you link me to a page where I can click one of the links?
July 16, 2017 at 7:24 am #350129July 16, 2017 at 11:13 am #350255TomLead DeveloperLead DeveloperAre 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.
July 17, 2017 at 3:44 am #350530RonnyI did try with gp hooks but its the same problem. Just wondering why google and twitter is working and facebook doesn’t.
July 17, 2017 at 9:24 am #350688TomLead DeveloperLead DeveloperNeither 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?
July 18, 2017 at 10:55 am #351291RonnyHuh,
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!July 18, 2017 at 6:49 pm #351430TomLead DeveloperLead DeveloperGlad you got it working! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.