-
AuthorPosts
-
June 12, 2021 at 10:35 pm #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
June 15, 2021 at 7:56 am #1305730Hey 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,
IsmaelJune 15, 2021 at 7:14 pm #1305883Hi,
your answer has not the faintest relation to my question and my request is clear.
Please read the code!
thanxMax
June 16, 2021 at 3:21 pm #1306049Hi,
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,
YigitJune 16, 2021 at 4:27 pm #1306066Hello 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
June 18, 2021 at 4:53 pm #1306414Hi 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,
YigitJune 20, 2021 at 12:57 pm #1306559Hello Yigit
yes, that worked.
Thank youkind regards
MaxJune 20, 2021 at 9:41 pm #1306602Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.