I'm having some trouble outputting canonical tags on my WordPress/WooCommerce website.
So basically, we have several variations of the same product set up as simple products. Because of this we have duplicate content, so we want to tell search engines that the central source of information is a landing page we have set up for each product via canonical tag.
This an example of the code we have currently. All code is in our header.php file:
<?php
// Achilles Desert Hawk UHP
if(is_product( array( '245-40-r20-99v-achilles-desert-hawk-uhp-e-c-72', '245-45-r20-99v-achilles-desert-hawk-uhp-e-c-72', '255-45-r20-105v-achilles-desert-hawk-uhp-f-c-72' )))
{
echo '<link rel="canonical" href="http://ift.tt/1nNd8t0" />';
}
// General Grabber GT
elseif(is_product( array( '195-80-r15-96h-general-grabber-gt-e-c-71', '205-70-r15-96h-general-grabber-gt-e-c-71', '205-80-r16-104t-general-grabber-gt-e-c-72', '215-60-r17-96h-general-grabber-gt-e-c-71', '215-65-r16-98h-general-grabber-gt-e-c-71', '215-65-r16-98v-general-grabber-gt-e-c-71', '215-70-r16-100h-general-grabber-gt-e-c-71', '225-55-r17-97v-general-grabber-gt-e-c-71', '225-55-r18-98v-general-grabber-gt-e-c-71', '225-60-r18-100h-general-grabber-gt-e-c-71', '225-65-r17-102v-general-grabber-gt-e-c-71', '225-70-r16-103h-general-grabber-gt-e-c-71', '235-50-r18-97v-general-grabber-gt-e-c-71' )))
{
echo '<link rel="canonical" href="http://ift.tt/1mdpubV" />';
}
// Kumho Road Venture AT KL78
elseif(is_product( array( '30-950-r15-104s-kumho-road-venture-at-kl78-f-e-78', '195-80-r15-100s-kumho-road-venture-at-kl78-e-e-74', '205-75-r15-97s-kumho-road-venture-at-kl78-e-e-74', '205-80-r16-104s-kumho-road-venture-at-kl78-e-e-74')))
{
echo '<link rel="canonical" href="http://ift.tt/1nNd8Je" />';
}
?>
So basically, the problem is that the respective canonical links aren't being outputted to the correct pages.
Here's an example: http://ift.tt/1mdpuZF
This should have the following line of code between the tags:
<link rel="canonical" href="http://ift.tt/1nNd8Je" />
but instead it says:
<link rel="canonical" href="http://ift.tt/1nNd8t0" />
If anyone could please advise on this it would be much appreciated as I can't figure it out :)
Aucun commentaire:
Enregistrer un commentaire