Ticket #22879: 22879.diff
File 22879.diff, 1.2 KB (added by , 9 years ago) |
---|
-
wp-includes/link-template.php
3268 3268 * @global WP_Query $wp_the_query 3269 3269 */ 3270 3270 function rel_canonical() { 3271 if ( !is_singular() ) 3272 return; 3271 $link = false; 3272 if ( is_singular() ) { 3273 global $wp_the_query; 3274 if ( !$id = $wp_the_query->get_queried_object_id() ) 3275 return; 3273 3276 3274 global $wp_the_query; 3275 if ( !$id = $wp_the_query->get_queried_object_id() ) 3276 return; 3277 $link = get_permalink( $id ); 3277 3278 3278 $link = get_permalink( $id ); 3279 if ( $page = get_query_var('cpage') ) 3280 $link = get_comments_pagenum_link( $page ); 3281 } else if ( is_home() || is_front_page() ) { 3282 $link = get_home_url(null, '/'); 3283 } else if ( is_search() ) { 3284 global $wp_the_query; 3285 if ( empty( $wp_the_query->query_vars['s'] ) ) { 3286 return; 3287 } 3288 $link = esc_url( 3289 add_query_arg( 3290 's', 3291 $wp_the_query->query_vars['s'], 3292 get_home_url(null, '/') 3293 ) 3294 ); 3295 } 3279 3296 3280 if ( $page = get_query_var('cpage') ) 3281 $link = get_comments_pagenum_link( $page ); 3282 3283 echo "<link rel='canonical' href='$link' />\n"; 3297 if ( $link ) { 3298 echo "<link rel='canonical' href='$link' />\n"; 3299 } 3284 3300 } 3285 3301 3286 3302 /**