diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php
index 12b2445aa1..2e12bd774c 100644
|
a
|
b
|
function redirect_canonical( $requested_url = null, $do_redirect = true ) { |
| 317 | 317 | $paged = get_query_var('paged'); |
| 318 | 318 | $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] ); |
| 319 | 319 | if ( !is_feed() ) { |
| 320 | | if ( $paged > 1 && !is_single() ) { |
| | 320 | if ( $paged > 1 && !is_singular() ) { |
| 321 | 321 | $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged'); |
| 322 | | } elseif ( !is_single() ) { |
| | 322 | } elseif ( !is_singular() ) { |
| 323 | 323 | $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : ''; |
| 324 | 324 | } |
| 325 | 325 | } elseif ( $paged > 1 ) { |
diff --git a/tests/phpunit/tests/canonical/paged.php b/tests/phpunit/tests/canonical/paged.php
index 8f1dbfdab0..9a8ad7de2c 100644
|
a
|
b
|
class Tests_Canonical_Paged extends WP_Canonical_UnitTestCase { |
| 22 | 22 | |
| 23 | 23 | $this->assertCanonical( $paged, $link ); |
| 24 | 24 | } |
| 25 | | } |
| 26 | | No newline at end of file |
| | 25 | |
| | 26 | /** |
| | 27 | * Ensure paged canonical redirect applies to pages. |
| | 28 | * |
| | 29 | * @ticket 28081 |
| | 30 | */ |
| | 31 | function test_page_with_paged_query_var() { |
| | 32 | $post_id = self::factory()->post->create( array( |
| | 33 | 'post_status' => 'publish', |
| | 34 | 'post_title' => 'Alexander Hamilton.', |
| | 35 | 'post_content' => 'My name is Alexander Hamilton.', |
| | 36 | 'post_type' => 'page', |
| | 37 | ) ); |
| | 38 | |
| | 39 | $link = parse_url( get_permalink( $post_id ), PHP_URL_PATH ); |
| | 40 | $paged = $link . 'page/3/'; |
| | 41 | |
| | 42 | $this->assertCanonical( $paged, $link ); |
| | 43 | } |
| | 44 | } |