For store owners using the Divi theme along with WooCommerce, controlling how products are displayed is crucial to enhancing the user experience and increasing sales. One common request is the ability to randomly sort WooCommerce products using Divi’s modules. Displaying products in a random order can help showcase a broader range of inventory and keep content fresh for returning customers.

Why Use Random Product Sorting in Divi WooCommerce?

There are multiple reasons why you might want to randomly sort your products:

  • Increase Product Visibility: Shuffling products can bring hidden or low-performing items to the front of the store.
  • Boost Engagement: Returning visitors get a different experience each time, reducing the chance of them seeing the same items over and over.
  • Encourage Discoverability: Customers are more likely to explore when the layout is dynamic.

Divi and WooCommerce Integration

Divi integrates tightly with WooCommerce through its built-in modules like the Shop Module. This module enables you to display products by category, popularity, featured products, or recent additions. However, by default, it doesn’t allow for random sorting out of the box. To get around this limitation, you will need to apply a few customizations.

How to Enable Random Product Sorting

There are a few different strategies you can use to enable random sorting of WooCommerce products in Divi:

1. Custom PHP Snippet (Recommended for Developers)

This method involves adding a small PHP function to your theme’s functions.php file. Here’s a simple snippet you can use:


function sort_products_randomly( $query ) {
    if ( ! is_admin() && $query->is_main_query() && is_shop() ) {
        $query->set( 'orderby', 'rand' );
    }
}
add_action( 'pre_get_posts', 'sort_products_randomly' );

This code modifies the default product query on the shop page so that products are randomly ordered each time the page is loaded.

2. Use a Plugin

If you’re not familiar with coding and want an easier, no-code solution, you can use third-party WordPress plugins designed to randomize post or product orders. Some of the popular plugins include:

  • WP Random Post Order
  • Advanced WooCommerce Product Sorting Options
  • Product Shuffle for WooCommerce

These plugins typically provide an option to control random order either globally or on specific product categories.

3. Divi Shop Module via Shortcodes

If you’re using the Divi Builder, you may add a WooCommerce shortcode inside a text module. The basic shortcode for this would look like:

This shortcode displays eight randomly chosen products anywhere you place the module. This method is especially flexible when building custom layouts within the Divi Builder.

Styling Randomly Sorted Products in Divi

Just like with standard product listings, you can customize the appearance of these randomly sorted products using the Divi design settings. Adjust grid layout, spacing, colors, and more using Divi’s built-in design options.

Important Considerations

While random sorting can be visually exciting, it’s important to consider potential performance implications—especially for large stores. Randomized database queries can add load time. Always test your changes and monitor site speed before and after implementing random sorting.

Conclusion

Random sorting of WooCommerce products in Divi is a powerful way to create dynamic user experiences that encourage exploration and improve visibility for items that may otherwise go unnoticed. Whether you use custom PHP code, a plugin, or a simple shortcode, Divi provides the flexibility to accommodate this popular feature with ease.

FAQ

  • Q: Will random sorting affect SEO?
    A: No, random sorting changes only the display order on the frontend. Product URLs and content remain the same.
  • Q: Can I randomize products only on certain pages?
    A: Yes. Custom functions and shortcodes can be conditionally used only on targeted pages, like category or landing pages.
  • Q: Will this work on mobile devices?
    A: Yes, random sorting works the same on all devices. Divi’s responsive design ensures consistency.
  • Q: Is there a way to combine random sorting with other filters?
    A: Some advanced plugins or custom development may allow combining random order with price, category, or tags.
Scroll to Top
Scroll to Top