You are here:  » Social Link


Social Link

Submitted by Tobix on Wed, 2021-01-06 09:07 in

Hi, David,
I am very happy with how I am making my price comparator. I have some requests to make and sorry if I will stress you a little :)

Let's start with the first one I installed the share function on social networks including facebook, twitter and pinterest. All previews work except on facebook. How can I apply? thanks.
How can I install the link share on whatsapp?

{link saved}

Submitted by support on Wed, 2021-01-06 10:59

Hi Tobix,

It may be necessary to filter the canonical URL in order for sharing links to work correctly. To try this, add the following code to the end of pto.php just before the closing PHP tag:

add_filter("get_canonical_url","pto_get_canonical_url",99);
function pto_get_canonical_url($url)
{
  global $pto_q;
  global $pto_module;
  if ($pto_q || $pto_module)
  {
    $url = "http".(isset($_SERVER["HTTPS"])?"s":"")."://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
  }
  return $url;
}

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Wed, 2021-01-06 11:41

unfortunately it doesn't work

Submitted by support on Wed, 2021-01-06 11:46

Hi,

I've modified the above to use a higher priority (99) - please could you give that a go, if still no joy if you could let me know an example product page (I'll remove before publishing your reply) with the above code in place and I'll take a look...

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Wed, 2021-01-06 11:48

Found the problem is the Yoast Seo plugin. Deactivating it all works!

Submitted by support on Wed, 2021-01-06 11:55

Hi Tobix,

The Yoast SEO plugin provides its own hook for overriding the canonical, so if you did want it enabled try adding the following line after the above code:

add_filter("wpseo_canonical","pto_get_canonical_url");

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Wed, 2021-01-06 12:06

It seems to work. Cache gate I tell you.
If I would like to put social icons instead of text, what should I do?

Submitted by support on Wed, 2021-01-06 13:06

Hi Tobix

That would depend on how you have integrated the social links but if you have simply added code to the templates (wp-admin > Settings > PriceTapestry.org) then it should just be a case of uploading the icons you want to use to your site and then changing the text in the link to an img tag e.g. if you have;

<a href='https://share.example.com/ref'>example.com</a>

Then if you upload an icon example.png, the link would be:

<a href='https://share.example.com/ref'><img src='/example.png' /></a>

Cheers,
David.
--
PriceTapestry.com

Submitted by Tobix on Wed, 2021-01-06 18:01

Good! :)