Merge pull request #23159 from woocommerce/fix/23157
If orderby is used on static homepage, force query to be a page query
This commit is contained in:
commit
15aa298585
|
@ -258,8 +258,11 @@ class WC_Query {
|
|||
return;
|
||||
}
|
||||
|
||||
// Fixes for queries on static homepages.
|
||||
if ( $this->is_showing_page_on_front( $q ) ) {
|
||||
|
||||
// Fix for endpoints on the homepage.
|
||||
if ( $this->is_showing_page_on_front( $q ) && ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) {
|
||||
if ( ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) {
|
||||
$_query = wp_parse_args( $q->query );
|
||||
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->get_query_vars() ) ) ) {
|
||||
$q->is_page = true;
|
||||
|
@ -271,7 +274,7 @@ class WC_Query {
|
|||
}
|
||||
|
||||
// When orderby is set, WordPress shows posts on the front-page. Get around that here.
|
||||
if ( $this->is_showing_page_on_front( $q ) && $this->page_on_front_is( wc_get_page_id( 'shop' ) ) ) {
|
||||
if ( $this->page_on_front_is( wc_get_page_id( 'shop' ) ) ) {
|
||||
$_query = wp_parse_args( $q->query );
|
||||
if ( empty( $_query ) || ! array_diff( array_keys( $_query ), array( 'preview', 'page', 'paged', 'cpage', 'orderby' ) ) ) {
|
||||
$q->set( 'page_id', (int) get_option( 'page_on_front' ) );
|
||||
|
@ -285,6 +288,12 @@ class WC_Query {
|
|||
$q->is_singular = true;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty( $_GET['orderby'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
|
||||
$q->set( 'page_id', (int) get_option( 'page_on_front' ) );
|
||||
$q->is_page = true;
|
||||
$q->is_home = false;
|
||||
$q->is_singular = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Fix product feeds.
|
||||
|
|
Loading…
Reference in New Issue