Opened 8 years ago
Last modified 5 years ago
#37530 new defect (bug)
is_front_page() is based on wrong data -> gives wrong results
Reported by: | TheInfinity | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.5.3 |
Component: | Query | Keywords: | has-patch needs-testing needs-unit-tests |
Focuses: | Cc: |
Description
1) is_front_page() is based on the SQL query, so it always gives back false when you try to use it eg at pre_get_posts. If it has no way to figure it out if it's the front page or not, it should return null instead
2) is_front_page() in themes gives the wrong result false back when you set an static page for the front page and then modify the main query on start page to posts or any other custom post type except page. This forces you to make an additionally SQL query instead of using the main query to build a custom front page.
Both is because of this: https://core.trac.wordpress.org/browser/tags/4.5.3/src/wp-includes/query.php#L4458 . This does not really make sense to get the front page.
Attachments (1)
Change History (9)
This ticket was mentioned in Slack in #core by sagarmultidots. View the logs.
8 years ago
#5
@
8 years ago
- Component changed from General to Query
Thanks for the patch, @dots. This will need unit tests that demonstrate the bug and demonstrate that the fix works as expected.
This ticket was mentioned in Slack in #core by johnbillion. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by mdchiragpatel. View the logs.
8 years ago
#8
@
5 years ago
- Milestone set to Future Release
@dots are you able to work on adding unit tests? Here is some documentation to help get started: https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/.
Now is_front_page() function is working when you set an static page for the front page and then modify the main query on start page to posts or any other custom post type except page.