2nd Door Of Our Advent Calendar – Support in WordPress for rel=”canonical”

WordPress-Christmas-02
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:

'; ?>

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 wp-includes/default-filters.php, the link-tag to the hook wp_head.

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

Posted

in

by

Comments

2 responses to “2nd Door Of Our Advent Calendar – Support in WordPress for rel=”canonical””

  1. […] war’s schon. Gefunden habe ich diesen WP-Hack bei WP Engineer im Adventskalender. Weitere Artikel zum […]

  2. Dam Milward Avatar

    Awesome. We’ve had a couple of requests to integrate this with the WP e-Commerce Plugin for products. Will do!!