Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #457681

    https://kriesi.at/support/topic/masonry-gallery-how-to-sort-by-random/

    This topic is unfortunately closed, but the solution provided in it doesn’t work anymore after recent updates :/

    #457968

    Hi iheartwine!

    When you edit the shortcode scroll down and you’ll see the “Order by” option which you can set to “Random”. This was added in one of the later Enfold versions.

    Best regards,
    Elliott

    #919130

    Hello Elliot and Dude,
    the solution works for me but I cannot use it for only a certain gallery. It would affect all galleries.
    So how can I randomly sort only one gallery? (e.g. with a custom_class)

    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;
    }

    Kind regards Axel

    • This reply was modified 6 years, 8 months ago by doppelaxel.
    #919171

    Hi,

    You might want to add some conditional tags to filter the pages where you want it to apply, please refer to the wordpress codex: https://codex.wordpress.org/Conditional_Tags
    Let us know if this helps :)

    Best regards,
    Nikko

    #919309

    Thanks for your quich reply Nikko.

    But the two galleries are one the same page. Only one of them should randomly display. Therefore I need to filter an id or similar. Is this possible?
    Or maybe a custom class?

    Kind regards Axel

    #919595

    Hi Axel,

    I see that’s pretty complicated though it’s possible, it would take some time to do it and outside the scope of our support. :(

    Best regards,
    Nikko

    #998607

    Should be able to set a class or ID to the section where your gallery is and with some creative conditionals targeting said class or ID, you should be able to do this. I haven’t tried, but in theory it should be more than possible that way.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.