You are here:  » Canonical link


Canonical link

Submitted by marco@flapper on Fri, 2012-11-02 10:44 in

Hi,
I set Header Display to true so the canonical links are displayed instead of a link to the shopper page (see http://www.pricetapestry.org/node/136).

But this setting surpresses the wp_head(). And I need that as I just enabled http://silktide.com/cookieconsent/code.

So I set the Header Display to false again but then I'm back into the situations where I have two canonical links in the source of a product page/search result: one being the shopper page and the other one being the correct one.

Do you know a solution for this so that I can use the header code and also have the one correct canonical link.

Submitted by support on Fri, 2012-11-02 11:31

Hello Marco,

I am testing a modification to be included in forthcoming update to PriceTapestry.org for WordPress (coming shortly after the Joomla version beta is released) which hooks into the WordPress API functions for returning page URLs and returns the PriceTapestry.org generated "virtual" page URL if the current permalink is the container page URL (e.g. /shopping).

To give this a go, add the following code to the end of pto.php, just before the closing PHP tag:

function pto_link($link)
{
  global $pto_config_permalink;
  if ($link == get_bloginfo('url').$pto_config_permalink)
  {
    $link = get_bloginfo('url').$_SERVER["REQUEST_URI"];
  }
  return $link;
}
add_filter('page_link','pto_link');
add_filter('post_link','pto_link');
add_filter('post_type_link ','pto_link');
add_filter('the_permalink','pto_link');

Then view your page again. You may now have 2 canonical headers, however the one generated by your SEO plugin should now show the virtual PriceTapestry.org generated link by way of $_SERVER["REQUEST_URI"].

If that's done the trick, you can remove the PriceTapestry.org generated version by commenting out or deleting the following code at line 180 of pto.php:

  print "<link rel='canonical' href='".$pto_canonical."' />";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Fri, 2012-11-02 12:45

I added the code but it didn't work.

I used another theme (twentyeleven) but still not working. I switched of SEO plugin but in both cases I still two different canonical links:
one to shopper page and the other one correct.

Submitted by support on Fri, 2012-11-02 13:43

Hi Marco,

I know you're working with modified beta files - could you check that your pto.php has at or near line 161 this code:

  remove_action('wp_head', 'rel_canonical');

If not, search for the following code at line 148:

    if ($pto_config_headerExclusivity)

...and REPLACE with:

    remove_action('wp_head', 'rel_canonical');
    if ($pto_config_headerExclusivity)

Let me know if that achieves the single, correct canonical, and I'll look into further hooks to ensure that your SEO plugin is able to compute the correct URL...

Cheers,
David.
--
PriceTapestry.com

Submitted by Mark Hennessy on Tue, 2013-10-08 08:54

Hi David,

Slight bump here.

I have employed some on page SEO tools to help makes my pages comply a little better. A common theme seems to be related to canonical links.

I am trying to get my head around exactly what it is and what needs fixing but I want to know if the later versions of the plugin perhaps rectify this.

Most likely of course it is something I have done!

Mark

Submitted by Mark Hennessy on Tue, 2013-10-08 09:03

Just to update, the error via moz.com is

"No More Than One Canonical URL Tag"

A right click page source on my product shows a canonical url both for my SEO Plugin as well as PT

Submitted by support on Tue, 2013-10-08 09:40

Hi Mark,

I've just referred back to the last copy of pto.php that I forwarded by email and your version is creating a canonical tag by the following code at line 325:

  print "<link rel='canonical' href='".$pto_canonical."' />";

Commenting out or deleting that line will prevent the plugin generated canonical from being created, if you're happy that your SEO plugin generated version is correct. If it's not, for example it's pointing to "/shopping" forward your latest pto.php and I'll add the update for that so that the hook used by SEO plugins to generate a canonical header is correct for the virtual product pages etc.,

Cheers,
David.
--
PriceTapestry.com

Submitted by Mark Hennessy on Tue, 2013-10-08 10:08

I saw the same post on your forums a few minutes ago and have made the change. Everything seems great now :)

Now...onto the other on site optimizations!

Submitted by marco@flapper on Thu, 2013-10-10 15:14

Hi,
My pto.php 2.0 generates a canonical link to the shoppper page (container url).

I looked for the Header Display to true in the advanced settings, but it doesn't seem to be there in 2.0?

Could you take a look?

An example url is:

{link saved}

Submitted by support on Thu, 2013-10-10 15:25

Hi Marco,

Please could you email me your current pto.php and I'll double-check that. Version 2.0 doesn't have the "Header Exclusivity" setting because the plugin now intercepts the page URL hooks which should be returning the correct page URL to the SEO plugin...

Cheers,
David.
--
PriceTapestry.com