Forum
Social Media sharing links
How can I put a social share link to a specific page and not only to the homepage? What do I have to add to the path?
<a href="<a href="https://www.facebook.com/sharer/sharer.php?u=http%3A//www..domain.com">Share on Facebook</a>
Thanks!
Hi Martin,
I think you might be able to do it like this:
Hi Simon
Unfortunately it does not work. Beside some errors in the code when I try this:
I get this error message:
Fatal error: Call to a member function get_page() on null in domain.com/perch/templates/pages/project.php
Thank you for your much appreciated help! Martin
You would need:
Great it works! One more thing: any idea what I should to the code add that FB's output is equal to the description tag of the page?
Thank you!
The description from the page attributes?
Yes, I thought this would be easier than any text out from the content?
It is, yes: https://docs.grabaperch.com/functions/page-attributes/perch-page-attribute/
I have tried to put both variables, but it does not output both, I see instead the landing page description only. Can you please have a look at my code?
Thank you, Drew!
echo perch_page_attribute('description');
only needs to be
perch_page_attribute('description');
What output do you get?
If I do so
I get the title and description of the landing page. If I just put get_page I get the correct page but as text an conditional comment (<!--[if lte IE 8]>...<![endif]-->) that I had inside the header. I deleted it but can't get it away and so the correct description is not displayed. Please try yourself and look what you get: https://dev.nordland.dieweberei.ch/kmar.php
Many thanks!
What are you doing to output the description in the head of the page? It doesn't seem like this should be so hard.
Right, shouldn't be difficult...
I use this for the description
as you see in the header the output is correct:
So are you saying that this outputs nothing?
No, no. I get the correct description tag in the page header. But it is not used for the facebook share...
So what does that line output?
For some reason the conditional comment was making the problems. It's now working. Thanks!