Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

product sorting

Home / Forums / Virtue Theme / product sorting

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
December 1, 2016 at 1:07 pm

Hi Ben
Probably you could help me,

what template i should overwrite in my child theme to make this script working?

add_action( 'pre_get_posts', 'gb_exclude_category' );
function gb_exclude_category( $query ) {
if ( $query->is_main_query() ) {

$query->set( 'meta_key', '_stock_status' );
$query->set( 'orderby', array('meta_value' => 'ASC', 'title' => 'ASC') );

}
}

I just want to show out of stock products at the end in shop/ archive pages and at the same time display them in alphabetical order.

Actually this code works, if I put it in function.php, but it brakes post/pages/media in my wp-admin so i can’t edit any other post_types. So i think i should paste it in product-archive template to make it working only there.

  • The forum ‘Virtue Theme’ is closed to new topics and replies.