Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active June 16, 2017 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/7b1d298baf55121ec3a54e63b5f8b009 to your computer and use it in GitHub Desktop.
Save cliffordp/7b1d298baf55121ec3a54e63b5f8b009 to your computer and use it in GitHub Desktop.
Image Widget Plus - Randomize order of all Slideshows
<?php
/**
* Image Widget Plus - Randomize order of all Slideshows
*
* From https://gist.github.com/cliffordp/7b1d298baf55121ec3a54e63b5f8b009
* For https://theeventscalendar.com/support/forums/topic/image-widget-pro-slideshow-and-random/
*
* @link https://theeventscalendar.com/product/wordpress-image-widget-plus/
*
* @see Tribe__Image__Plus__Widget::widget()
*/
add_filter( 'tribe_image_plus_widget_instance', 'cliff_image_widget_plus_randomize_slideshow' );
function cliff_image_widget_plus_randomize_slideshow( $instance ) {
// only if we are in a Slideshow type of IW+ widget
if ( 'slideshow' === $instance['display'] ) {
shuffle( $instance['attachments'] );
}
return $instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment