Last active
August 29, 2015 14:19
-
-
Save chrdesigner/ad52f4254520ea1c4c15 to your computer and use it in GitHub Desktop.
Custom sorting options - alphabet order - WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Custom sorting options | |
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); | |
function custom_woocommerce_get_catalog_ordering_args( $args ) { | |
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); | |
if ('title_asc' == $orderby_value) { | |
$args['orderby'] = 'title'; | |
$args['order'] = 'ASC'; | |
$args['meta_key'] = ''; | |
}elseif ('title_desc' == $orderby_value) { | |
$args['orderby'] = 'title'; | |
$args['order'] = 'DESC'; | |
$args['meta_key'] = ''; | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment