Tagged: Masonry Gallery, random
Hi,
trying to random-sort my 100+ masonry-galleries. I was searching for existing topics but still need help!
Hi Stefan!
If you want to use the “load more” button or the pagination you can’t sort the images randomly because wordpress would query/show the same images over and over again. If you do not use a pagination or load more button use this code and insert it at the bottom of functions.php:
add_filter('avia_masonry_entries_query', 'avia_random_image_query', 10, 2);
function avia_random_image_query($query, $params)
{
if(!empty($query['post_mime_type']) && $query['post_mime_type'] == 'image')
{
$query['orderby'] = "rand";
}
return $query;
}
for a random sort order.
Best regards,
Peter
Thank you Dude, that´s perfect!
even with “load more” :-)
this problem is solved!
Cheers, Stefan
Hi!
Great :)
Regards,
Peter