lundi 4 décembre 2017

Randomize WooCommerce "Shop By Category"

I'm currently working on a WooCommerce webstore. I have the shop by category option selected and the front page currently shows the first 3 categories.

Instead of the first three categories I would like it to show 3 random categories.

I was able to add a custom function to my function.php (code below) to increase the number of categories listed (to 10) but I'm not able to have the categories show up in a random order.

add_filter('storefront_product_categories_shortcode_args','custom_storefront_category_per_page' );

// Category Products
function custom_storefront_category_per_page( $args ) {
    $args['number'] = 10;
    return $args;
}

I have tired setting $args['orderby'] = "rand"; with no luck. Im guessing that only works for products. What function should I be changing to have the "Shop By Category" section on the front page list 3 random categories instead of 3 categories in AESC or DESC order?




Aucun commentaire:

Enregistrer un commentaire