rel=canonical for singular pages. see #10115
git-svn-id: http://svn.automattic.com/wordpress/trunk@11777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e15de47ed7
commit
04d3d11213
|
@ -178,6 +178,7 @@ add_action('wp_head', 'noindex', 1);
|
|||
add_action('wp_head', 'wp_print_styles', 8);
|
||||
add_action('wp_head', 'wp_print_head_scripts', 9);
|
||||
add_action('wp_head', 'wp_generator');
|
||||
add_action('wp_head', 'rel_canonical');
|
||||
add_action('wp_footer', 'wp_print_footer_scripts');
|
||||
if(!defined('DOING_CRON'))
|
||||
add_action('sanitize_comment_cookies', 'wp_cron');
|
||||
|
|
|
@ -1806,4 +1806,22 @@ function plugins_url($path = '', $plugin = '') {
|
|||
return apply_filters('plugins_url', $url, $path, $plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output rel=canonical for singular queries
|
||||
*
|
||||
* @package WordPress
|
||||
* @since 2.9.0
|
||||
*/
|
||||
function rel_canonical() {
|
||||
if ( !is_singular() )
|
||||
return;
|
||||
|
||||
global $wp_the_query;
|
||||
if ( !$id = $wp_the_query->get_queried_object_id() )
|
||||
return;
|
||||
|
||||
$link = get_permalink( $id );
|
||||
echo "<link rel='canonical' href='$link' />\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue