From bb0d1af58fbea6b8f93d2390a8b3bab47ad756c2 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Sat, 26 Dec 2015 04:27:43 +0000 Subject: [PATCH] Canonical: Output correct canonical links for paged posts when not using pretty permalinks. Props peterwilsoncc. Fixes #34890 git-svn-id: https://develop.svn.wordpress.org/trunk@36096 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index ca6ccfcf88..b580a0a8a2 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -3502,8 +3502,12 @@ function rel_canonical() { $url = get_permalink( $id ); $page = get_query_var( 'page' ); - if ( $page ) { - $url = trailingslashit( $url ) . user_trailingslashit( $page, 'single_paged' ); + if ( $page >= 2 ) { + if ( '' == get_option( 'permalink_structure' ) ) { + $url = add_query_arg( 'page', $page, $url ); + } else { + $url = trailingslashit( $url ) . user_trailingslashit( $page, 'single_paged' ); + } } $cpage = get_query_var( 'cpage' );