WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#29587 closed defect (bug) (duplicate)

Duplicate content problem with URLs when using WP_Query in front-page.php

Reported by: henry.wright Owned by:
Milestone: Priority: normal
Severity: major Version: 4.0
Component: Query Keywords:
Focuses: Cc:
PR Number:

Description

I have "Front page displays" set to "A static page".

"Front page" is set to a page I created via Pages > Add new.
"Posts page" is also set to a page I created via Pages > Add new.

The query I'm using in front-page.php is:

$args = array(
    'post_type' => 'post',
    'page' => $page
);
$query = new WP_Query( $args );

If I visit example.com, I see the first page of my query results are displayed (as expected).

Problem:

When I visit a URL such as the following:

  • http://example.com/page/1/

I'd expect to be redirected to example.com.

  • http://example.com/page/2/

I'd expect to see the next page of results.

  • http://example.com/page2/

I'd expect to get a 404 error page.

  • http://example.com/page/29876987/

I'm not even sure what I should see here (I don't have that many posts).

But, in each case above, all that is shown is the first page of results. Nothing on the page changes.

I think this is a bug so am reporting. The title I've given this ticket is the best I could come up with (I was thinking for ages), please feel free to update it to something better.

Change History (4)

#1 @SergeyBiryukov
5 years ago

  • Component changed from General to Query

#2 @henry.wright
5 years ago

  • Severity changed from normal to major
  • Summary changed from Problem with URLs when using WP_Query in front-page.php to Duplicate content problem with URLs when using WP_Query in front-page.php

I just spotted some related info in the Creating a Static Front Page article:

Static front pages are not intended to be paged. None of the WordPress Previous / Next page link functions work with a static front page. Pagination on a static front page uses the page query variable, not the paged variable. See the WP_Query for details.

So I shouldn't have expected to see paged query results.

But, the duplicate content problem remains. For example:

example.com/page2/
example.com/page23/
example.com/page35/ ... and so on...

example.com/page/1/
example.com/page/2/ ... and so on..

...all result in the exact same content displayed as that on example.com.

Considering this affects the homepage, I think setting this ticket to major is appropriate? Please feel free to change back to normal if you feel differently.

#3 @henry.wright
5 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Querying was not the issue so am closing in favour of ticket #29655 which better explains the problem.

#4 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.