Photos in gallery view order

Hi and thanks for this plugin.

I use it inside a BuddyPress installation. In the home-page are displayed all the photos from our users.
Is there a way to display all photos in random order and not DESC (media-id)? Must i create a new shortcode or function for this?

Thanks for the help!

Hi @Forgo,

You wont need to write a new shortcode function. Instead use this code to randomize the order of the media displayed using rtmedia gallery shortcode. This will randomize order wherever you have used the shortcode. You can additionally put different checks for different pages if you want ex: is_home() for homepage only.

add_filter('rtmedia-model-order-by-query','randomize_media_order', 99, 1);  
function randomize_media_order( $order_by){  
    global $rtmedia_query;  
    if( isset ($rtmedia_query->is_gallery_shortcode) && $rtmedia_query->is_gallery_shortcode == true){  
        $order_by = ' ORDER BY RAND()';  
    return $order_by;  

Check and see if this satisfies your requirement.

Thank you Pushpak Patel!
I’ll try this asap.
Other questions:

  • Does this work with rtmedia version 3.2.6 or only with the latest version?
<li>The latest 2 arguments passed in the add_filter function (99,1) are the limits?</li>  
<li>Is there a way to show the latest n image (6 for example) and the other in random order?</li>  

Thank you!

Hello @Forgo,

  • This will work with 3.2.6 version of rtMedia.
  • '99' is the priority of the filter and '1' is number of arguments passed. check out this link for more info :
  • I am sorry to say this is not possible. You can either show them in some specific order based on media_id or title or any other field, or totally random.

Hi Pushpak Patel,

Will this work with version 3.0.12 ?

Also is it possible to change the order to either most commented on and/or most liked?
Can you please provide the code for each.
Thanks so much in advance :slight_smile:

Hi serks,

I am sorry to say it won’t work with rtMedia v3.0.12. It is pretty old version. Current version of rtMedia is v3.7.3

Hi Ritesh,

Thanks for your response.
I was wondering if I could hire a developer from rtCamp to upgrade rtMedia on my site, as well as customise a few extra things that I would like.

Is anyone available to do this for me? I am afraid of breaking something in the process.


Hi Serks,

You can contact here -> for any customization work related to rtMedia.

Hi Ritesh,

I tried to submit that form but it doesn’t let me.
It says “There was a problem with your submission. Errors have been highlighted below.”
but there is nothing highlighted and I filled in everything.


Hello @serks

Sorry for the trouble you had with our contact form. Now its working fine.
Also you can directly get in touch with me, for any further discussion.


Excuse me. What file should I change to rindomize order in the gallery widget?

What function could I use to display 6 or 9 thumbnails (that i could select the size) for a widget for example of random images that are in my gallery page.

Hi @supergrower,

Sorry for the delay in reply, are you still having the issue or it is resolved?

Hi @livingsurvival,

Can you please provide more detail about the issue?

I have a page that displays the photo albums my users upload. I would like to add a smaller thumbnail gallery of this on my homepage as a shortcode or widget. Or maybe just show the last photo that was uploaded or a random photo. “RECENTLY FROM THE GALLERY” for example.

@livingsurvival a simple shortcode like this used in your home page

[rtmedia_gallery global=true media_type=photo per_page=3]

would display the last three uploaded pics on your home page or if you want to randomize the display you can use the filter suggested by @pushpakpatelrtc above, if you want the filter to be applied only on the home page then add if is_home condition or do you want to display your thumbs on a widget in your home page?

I have been able to do just that, however, I would like to be able to display them in a smaller size if possible.

I can assure you that changes are currently been made to the core codes to accommodate this feature,but you can check this support Shortcode and media size for urgent fix…