Would like Gallery Images to change with every load.

I have created a gallery at https://dating.christiangays.com/members/members-media/

Currently it shows the images as they are uploaded by my members, meaning that the first images loaded will be at the bottom, and all images by one person are linked. I would like the images to be in random order, and to change every time the page is loaded.

The shortcodes for the app are at https://rtmedia.io/docs/features/gallery/

It appears that there is not a shortcode for what I want. Can you please tell me how to make images load in random order, and change with every load.

Thank you.
Support Access is granted.

  • Sajid

    Hello Mary,
    Hope you are doing good today :slight_smile:

    If there is no parameter given to set the sort order then we have to modify the core files of the plugin which is not recommended.

    But I try to come up with a following jQuery based code solution for you. Add it in functions.php file of your child theme or use it as mu-plugin.

    add_action( 'wp_footer', 'wpmudev_randomize_list_items', 99 );
    function wpmudev_randomize_list_items(){?>
    	<script type="text/javascript">
    			var $ul = $('.rtmedia-list');
    			$('li', $ul).sort(function(){
    			   return ( Math.round( Math.random() ) - 0.5 )
    <?php }

    If you go with mu-plugin route then, go to your /wp-content/ folder via FTP, and find the folder called "mu-plugins". If there is no folder with that name, then you'll want to create one. Then, create a file inside that folder, and give the file any name you like and paste the code in there.

    You don't need to activate that plugin, as it will be always be automatically activated. Please be sure to add a PHP start tag at the beginning of the code if you insert this code as a mu-plugin, like this:


    Take care and have a nice day :slight_smile:

    Best Regards,
    Sajid - WPMU DEV Support

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.