Opened 12 years ago
Last modified 5 years ago
#21096 new enhancement
Filter on is_front_page return value
Reported by: | CoenJacobs | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Query | Keywords: | needs-patch |
Focuses: | Cc: |
Description
When you set a page (as 'placeholder' with same slug) as front page which is actually a post type archive to front page, is_front_page() will always return false on that page. The return value of the is_front_page() function is not filterable.
Attached patch adds this filter in the most basic way.
Attachments (1)
Change History (7)
#1
follow-up:
↓ 2
@
12 years ago
This sounds like a bug in is_front_page(). We should try to fix it, instead of papering over it with a filter.
#2
in reply to:
↑ 1
@
12 years ago
- Keywords has-patch removed
Replying to scribu:
This sounds like a bug in is_front_page(). We should try to fix it, instead of papering over it with a filter.
You are right, that will be better. Think the problem is that the page which you set to the front page is no longer a page, but a post type archive. Therefore, this '$this->is_page( get_option( 'page_on_front' ) )' will never return true, since the current page is no page. So maybe this issue is in is_page() instead of this is_front_page() function?
#3
@
12 years ago
In our pre_get_posts query where we set the frontpage as the post type archive we have to set some conditionals for it to work:
$q->is_page = false; $q->is_singular = false; $q->is_post_type_archive = true; $q->is_archive = true;
Making is_page true gives us all kinds of errors such as
Notice: Undefined property: stdClass::$ID in /nfs/c08/h03/mnt/125403/domains/woocommerce.faultpress.com/html/wp-includes/query.php on line 3349
Possibly due to the fact we need to unset the page_id to get the post type query working:
$q->set( 'post_type', 'product' ); $q->set( 'page_id', '' );
Being able to simply set $q->is_front_page = true; would be another workaround (instead of the filter) but agree it would be better to have a fixed is_front_page() function.
Basic filter in place