daily pastebin goal
19%
SHARE
TWEET

WooCommerce - Set default shop order to random

lorro Mar 23rd, 2017 (edited) 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top