Understanding Randomization in Kadence Blocks: Galleries, Testimonials, and More
Content
A common request from users of the 'Gutenberg Blocks with AI by Kadence WP – Page Builder Features' plugin is the ability to randomize the display order of content in blocks like the Advanced Gallery, Testimonial carousel, and Post Grid. This article explains the technical reasons behind this limitation and explores potential workarounds.
The Core Issue: How Gutenberg Works
Unlike older WordPress shortcodes that generated content dynamically on each page load, Gutenberg blocks save their content as static HTML within the page's post content. This means the order of images in a gallery or testimonials in a carousel is fixed at the time you save the page in the editor. The block does not rebuild itself for each new visitor; it simply serves the pre-built HTML. This fundamental architectural difference is why a built-in 'randomize on page load' feature does not exist in these blocks.
Official Stance on Randomization
Based on community support threads, the 'Gutenberg Blocks with AI by Kadence WP – Page Builder Features' team has indicated they have no current plans to add true front-end randomization (where each visitor sees a different order) for several reasons:
- User Experience (UX): Randomization can frustrate visitors who return to a page expecting to find content in a specific location.
- Performance: Generating random orders on the front-end would require additional JavaScript processing, potentially slowing down page load times.
- Static Output: As explained above, the block output is designed to be static HTML for consistency and performance.
Potential Workarounds and Solutions
While a native one-click solution isn't available, here are some approaches users have considered:
1. Editor-Side Randomization (Static Output)
This is the most feasible type of feature that could potentially be added. You could manually randomize the order of your images or testimonials within the block editor before saving the page. This would create a new, static order that remains the same for all visitors until you manually change it again. Some users have requested a 'Randomize' button within the block settings to facilitate this.
2. Custom Development
For developers comfortable with code, two main approaches could be explored:
- PHP Filter: A custom PHP function could be hooked to filter the block's output before it is saved or served, potentially altering the order. This requires a strong understanding of WordPress plugin development.
- JavaScript Solution: Custom JavaScript could be written to run on the front-end after the page has loaded. This script would select the gallery container, randomize the order of the child elements (images), and then re-render them. This can be complex and may conflict with other scripts or the block's own functionality (like lightboxes or carousel features).
3. Feature Request
For those interested in a more user-friendly, editor-based randomize button, the best course of action is to formally submit a feature request. The 'Gutenberg Blocks with AI by Kadence WP – Page Builder Features' team reviews community feedback for future development planning.
Conclusion
The desire to randomize content is understandable for keeping a site dynamic. However, due to the static nature of Gutenberg block output and potential UX concerns, true per-visitor randomization is not a feature of the Kadence blocks discussed. The most practical solution for most users is to periodically manually reorder content within the editor. For those with coding skills, custom solutions are a possibility, though they are not officially supported.
Related Support Threads Support
-
Random Testimonialshttps://wordpress.org/support/topic/random-testimonials/
-
Enhancement: randomize gallery option and image clipping settinghttps://wordpress.org/support/topic/enhancement-randomize-gallery-option-and-image-clipping-setting/
-
How do we randomize the position of images like in the classic gallery?https://wordpress.org/support/topic/how-do-we-randomize-the-position-of-images-like-in-the-classic-gallery/
-
Gallery masonry layout image orderhttps://wordpress.org/support/topic/gallery-masonry-layout-image-order/
-
Randomize image order in Advanced Gallery?https://wordpress.org/support/topic/randomize-image-order-in-advanced-gallery/
-
Result position randomized, instead of just the question and choice.https://wordpress.org/support/topic/result-position-randomized-instead-of-just-the-question-and-choice/
-
Random image in Advanced Gallery or similarhttps://wordpress.org/support/topic/random-image-in-advanced-gallery-or-similar/
-
Random Order of Imageshttps://wordpress.org/support/topic/random-order-of-images-3/
-
Post Grid/Carousel Random Orderhttps://wordpress.org/support/topic/post-grid-carousel-random-order/
-
Randomize image order in Advanced Gallery?https://wordpress.org/support/topic/randomize-image-order-in-advanced-gallery-2/