Ticket #10115: rel_canonical.txt
File rel_canonical.txt, 366 bytes (added by , 16 years ago) |
---|
Line | |
---|---|
1 | function rel_canonical() { |
2 | if ( !is_singular() ) |
3 | return; |
4 | |
5 | global $wp_the_query; |
6 | if ( !$wp_the_query->get_queried_object_id() ) |
7 | return; |
8 | |
9 | $link = get_permalink( $wp_the_query->get_queried_object_id() ); |
10 | echo "<link rel='canonical' href='$link' />\n"; |
11 | } |
12 | |
13 | add_action( 'wp_head', 'rel_canonical' ); |