Advertisement
majeedraza

WooCommerce - Set default shop order to random

Mar 23rd, 2017
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. <?php
  2.   // WooCommerce - Set default shop order to random
  3.   add_filter('woocommerce_get_catalog_ordering_args', 'set_default_sort_order');
  4.   function set_default_sort_order($args) {
  5.      // see if the user has selected a sort order, if so, do not set the order
  6.      if ( !isset( $_GET['orderby'] ) ) {
  7.        $args['orderby'] = 'rand';
  8.      }
  9.     return ($args);    
  10.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement