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

    Hi,

    the code below works perfekt if you want display images in Masonry Galeries in random order

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

    But is there a posibility to display the images in random order only on certain pages. f.e. “page-id-573” and “page-id-578”

    Thank you for your help

    Best
    Sabine

    • This topic was modified 5 years, 3 months ago by sabine.
    #1126859

    Hey ingridbrauner,

    Please try using the code like this:

    
    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' && is_page(['573', '578'])) {
    		$query['orderby'] = "rand";
    	}
    
    	return $query;
    }
    

    Best regards,
    Victoria

    #1127207

    Hi Victoria,
    that’s exactly what I needed. Thank you so much for your help.
    Best
    Sabine

    #1127325

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Masonry Galerie: random image order only on certain pagees’ is closed to new replies.