Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1305421

    Hello
    this is the code to sort all images in a masonry gallery by random:

    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 what if i want to to keep the random order generally but want a normal order on a certain URL with the ID 99?

    Max

    #1305730

    Hey digitalprint2222,

    Thank you for the inquiry.

    Would you like to set a post or a gallery item as sticky? Having sticky items in the query is possible, but it may not work if the orderby parameter is set to random.

    // https://kriesi.at/support/topic/sticky-posts-not-displaying-forst/#post-1230187

    Best regards,
    Ismael

    #1305883

    Hi,
    your answer has not the faintest relation to my question and my request is clear.
    Please read the code!
    thanx

    Max

    #1306049

    Hi,

    Use the code as following

    add_filter('avia_masonry_entries_query', 'avia_random_image_query', 10, 2);
    function avia_random_image_query($query, $params)
    { 
    if(!is_page( 99 )){
     if(!empty($query['post_mime_type']) && $query['post_mime_type'] == 'image')
        { 
        $query['orderby'] = "rand"; 
        }
        return $query;
     }
    }

    Regards,
    Yigit

    #1306066

    Hello Yigit,
    it does not work.
    The page with the ID 99 shows no content (at least no gallery) at all when i use your code.
    The other pages do.

    Max

    #1306414

    Hi Max,

    Please try using the code as following

    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')
        { 
        if(!is_page( 99 )){
        $query['orderby'] = "rand";
        }
       }
        return $query;
    }

    Best regards,
    Yigit

    #1306559

    Hello Yigit
    yes, that worked.
    Thank you

    kind regards
    Max

    #1306602

    Hi,

    Did you need additional help with this topic or shall we close?

    Best regards,
    Jordan Shannon

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