Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #209807

    How can I randomize the order of the images in the slideshow (for example used on the startpage)?

    Also, is it possible to randomize the products shown when builiding a Template and using for example the “Products” model? In the setting we can sort by price, most recent and alphabetically.

    Thanks :)


    Hey artonglass!

    1.) That is possible but it will require a bit of modification. You need to hire a freelance developer to modify the slider script.

    2.) Please add this on functions.php:

    add_filter('woocommerce_get_catalog_ordering_args', 'avf_woocommerce_catalog_orderby');
    function avf_woocommerce_catalog_orderby( $args ) {
        $args['meta_key'] = '_price';
        $args['orderby'] = 'rand'; 
        return $args;

    Best regards,


    Hi, Thanks for the fast answer.

    2. This successfully sorts the product page. However it does not work when using the template builder and a Product-building block. In that case I choose the option “Use default (Defined in woocommerce->settings->catalog)”. The product page sorts randomly, but not the building blocks I use with the template builder.

    Thanks to the filter I had info to google this, and also found this:

    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 ( 'random_list' == $orderby_value ) {
    		$args['orderby'] = 'rand';
    		$args['order'] = '';
    		$args['meta_key'] = '';
    	return $args;
    add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' );
    add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' );
    function custom_woocommerce_catalog_orderby( $sortby ) {
    	$sortby['random_list'] = 'Random';
    	return $sortby;

    Which adds a “random” option to the sorting selectbox in the Woocommerce->settings->catalog. Choosing this does the same as your script, works fine on the product page, but this also fails to work on the Product building block in the Template Building. It always shows the same order.
    Anh ideas?



    If you want a random order open up /wp-content/themes/replete/includes/helper-template-dynamic.php and replace

    $avia_config['woocommerce']['disable_sorting_options'] = true;


    $avia_config['woocommerce']['disable_sorting_options'] = true;
    $orderBY = "rand";

    Best regards,


    That solved it.

    I had to make a little change however, so good to point out to any other eventual reader of this thread wanting to to the same is to add the line $orderBY = "rand";
    right after the line if(!$orderBY) $orderBY = "menu_order";

    In version 1.5 of Replete this is on line 512 in an original/unedited helper-template-dynamic.php.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Randomize order of images in the Slideshow?’ is closed to new replies.