Fix frontpage shop with orderby Closes #2581.

This commit is contained in:
Mike Jolley 2013-03-04 22:49:17 +00:00
parent d2f8cd6a4a
commit d80c88189c
2 changed files with 14 additions and 1 deletions

View File

@ -40,7 +40,6 @@ class WC_Query {
add_filter( 'wp', array( $this, 'remove_product_query' ) );
}
/**
* Hook into pre_get_posts to do the main product query
*
@ -55,6 +54,17 @@ class WC_Query {
if ( ! $q->is_main_query() )
return;
// When orderby is set, WordPress shows posts. Get around that here.
if ( $q->is_home() && 'page' == get_option('show_on_front') && get_option('page_on_front') == woocommerce_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->is_page = true;
$q->is_home = false;
$q->set( 'page_id', get_option('page_on_front') );
$q->set( 'post_type', 'product' );
}
}
// Special check for shops with the product archive on front
if ( $q->is_page() && 'page' == get_option( 'show_on_front' ) && $q->get('page_id') == woocommerce_get_page_id('shop') ) {

View File

@ -165,6 +165,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 2.0.2 - XX/03/2013 =
* Fix - Frontpage shop when 'orderby' is set.
= 2.0.1 - 04/03/2013 =
* Fix - Added an extra permalink flush after upgrade to save needing to do it manually.