Home > database >  Function to Sort related products by Product Title in WooCommerce
Function to Sort related products by Product Title in WooCommerce

Time:08-24

how to Sort related products by Product Title in WooCommerce without using a plugin?

CodePudding user response:

You can sort related products like this

add_filter( 'woocommerce_output_related_products_args', 'BN_order_related_priducts_by_title_asc', 20 );
  function BN_order_related_priducts_by_title_asc( $args ) {
        $args['orderby'] = 'title';
        $args['order'] = 'ASC';
 
    return $args;
}

Add the code to the functions.php file of your child theme.

  • Related