rel=canonical for singular pages. see #10115
git-svn-id: https://develop.svn.wordpress.org/trunk@11777 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dd4f9603cb
commit
7bc6b530f2
@ -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
Block a user