The Randomize Output Modifier for the Voxel WordPress Theme allows you to input a comma-separated list, such as a list of image Gallery IDs or taxonomies and outputs a number of random values each time the page is refreshed.
Whether you want to showcase a random image from a gallery or display a different taxonomy term on each visit, this modifier makes it easy to add variety to your site’s dynamic content.
In addition to the comma-separated list, you can provide additional input options, which are seamlessly integrated into the pool of potential outputs. This makes it easy to expand your choices without altering the original list, giving you greater control over the randomness while ensuring that the content remains fresh and engaging for your visitors.
Use Case
Displaying a random image
When applied to an Image widget, this modifier accepts a list of gallery IDs along with additional file IDs or dynamic tags. It then randomly selects a single image ID from the list to be displayed. The selected image changes with each page refresh, adding a dynamic touch to the content.
(additional options 1 and 2 are file IDs from the Media Libary)

Changing text output
When applied to a Text widget, this modifier randomly outputs either the original text or one of the additional options or dynamic tags that have been provided.
The example below is not ideal as the text output is static, but you could have a repeater of text options or a list of keywords, from which one is chosen at random. In that case, you would not add any additional options and the Mod would output one value from the given list.


Security implementations
The core of the modifier relies on the sanitization of input values to ensure that the data remains safe and clean for use in WordPress. The comma-separated list is sanitized using sanitize_text_field()
, which ensures that any unwanted characters or HTML tags are removed before being processed. Additionally, the modifier handles the additional input fields, ensuring that any data added by users is properly sanitized and validated before being incorporated into the randomized list. To further prevent XSS (Cross-Site Scripting) vulnerabilities, the selected value is passed through esc_html()
before being outputted to the page, ensuring that any content displayed is properly escaped.
Conclusion
In conclusion, the Randomize Output Modifier for Voxel offers a simple yet powerful solution for introducing dynamic, randomized content into your WordPress site.
By accepting comma-separated lists and additional input options, this modifier provides flexibility and ease of use, allowing you to add engaging features like rotating gallery images, random taxonomies, or diverse content displays with minimal effort.
Coupled with robust security measures such as input sanitization and output escaping, this tool ensures a safe and smooth user experience.
Whether you’re looking to spice up your site’s content or provide a more interactive experience for your visitors, the Randomize Output Modifier is an invaluable addition to your Voxel toolkit.