WordPress 2.9 will support the attribute
rel and his value
canonical, you can also read about it on an older post how to integrate the values and what’s about it. Therefore you don’t have to paste the HTML explicitly in your theme.
In previous versions of WordPress 2.9, the intergration is easy to do:
<?php if ( is_singular() ) echo '<link rel="canonical" href="' . get_permalink() . '" />'; ?>
Putting it in the header.php of the theme is the easiest way to have the link-tag in the
head of your frontend.
Since WordPress 2.9 it won’t be necessary because WordPress set with the help of the default filter, see
link-tag to the hook
add_action( 'wp_head', 'rel_canonical' );
Thereby it calls the function
rel_canonical(), which simply writes the HTML and passes the link of the article. Alternatively you can disable the filter and you can use it yourself.
remove_action( 'wp_head', 'rel_canonical' ); // to delete in head
2 responses to “2nd Door Of Our Advent Calendar – Support in WordPress for rel=”canonical””
[…] war’s schon. Gefunden habe ich diesen WP-Hack bei WP Engineer im Adventskalender. Weitere Artikel zum […]
Awesome. We’ve had a couple of requests to integrate this with the WP e-Commerce Plugin for products. Will do!!