Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #221391

    Hi,
    trying to random-sort my 100+ masonry-galleries. I was searching for existing topics but still need help!

    #221574

    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

    #221614

    Thank you Dude, that´s perfect!
    even with “load more” :-)
    this problem is solved!
    Cheers, Stefan

    #221618

    Hi!

    Great :)

    Regards,
    Peter

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘masonry gallery – how to sort by random’ is closed to new replies.