WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 9 months ago

#45894 new defect (bug)

is_home conditional tag returns incorrect value with home pagination

Reported by: man4toman Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.0.2
Component: Query Keywords: has-patch
Focuses: Cc:
PR Number:

Description

I create a index page with simple posts loop that paginate with 'the_posts_pagination' function, in default index 'is_home' returns true but when I navigate to page 2, 'is_home' returns true again!

The reading options is set on default values.

I check $wp_query in these 2 page, when 'is_page' is true we aren't in home.

So I add this condition and create the patch.

Attachments (2)

is_paged.png (23.2 KB) - added by man4toman 9 months ago.
Compare the $wp_query in 2 page
class-wp-query.php.patch (935 bytes) - added by man4toman 9 months ago.
The patch

Download all attachments as: .zip

Change History (5)

@man4toman
9 months ago

Compare the $wp_query in 2 page

@man4toman
9 months ago

The patch

#1 @man4toman
9 months ago

  • Keywords has-patch added; needs-patch removed
  • Summary changed from is_home conditional tag returns incorrect value with index pagination to is_home conditional tag returns incorrect value with home pagination

#2 @ChriCo
9 months ago

The naming of those conditional functions are quiet irritating, but i would say, that your patch is a breaking change to WordPress.

The is_home indicates, if the query is for the blog homepage. Which is for page 1 and page n correct, because you're still running the "home"-query when you're on page 2, just with an LIMIT/OFFSET.

#3 @man4toman
9 months ago

Hi @ChriCo
I agree with you and also thought about this.

But if we consider the function's name, the is_home function should only be for the first page even in blog mode.

Unless we must change the name of is_home to is_blog_home or something like this to prevent this misunderstanding.

Totally we must conclude in this case.

Note: See TracTickets for help on using tickets.