Tagged: Masonry Gallery, sort
-
AuthorPosts
-
September 4, 2021 at 7:36 am #1319714
Hi Support,
we use masonry gallery without entry and it shows all images of wordpress mediathek – thats very nice!
How can we change the ordering of this view to sort by desc?
Thanks for your answer.
best regards!
Tobias
September 7, 2021 at 8:21 am #1319938Hey Tobias,
Thank you for the inquiry.
You can use this filter in the functions.php file to sort the masonry gallery item in descending order.
add_filter("avia_masonry_entries_query", function($query) { $query["order"] = "DESC"; return $query; }, 10, 1);
Please make sure to purge the cache after adding the snippet.
Best regards,
IsmaelSeptember 7, 2021 at 11:11 pm #1320025Hi Ismael,
i try but it doesn´t work. We also try orderby than order – the same. Please have a look at our Website. The images are still sorted in ascending order.
Best regards!
Tobias
- This reply was modified 3 years, 2 months ago by Tobias.
September 10, 2021 at 6:18 am #1320330Hi,
Thank you for the update.
Looks like the order parameter does not affect the sorting when post__in parameter is defined. Please try to reverse the order of the IDs in post__in array instead.
add_filter("avia_masonry_entries_query", function($query) { $query["post__in"] = array_reverse($query["post__in"]); return $query; }, 10, 1);
Best regards,
IsmaelSeptember 11, 2021 at 11:38 am #1320502Hi Ismael,
interesting, but unfortunately it does not work with it either. Do you have another idea?
Best regards!
Tobias
September 13, 2021 at 1:08 am #1320607Hi,
Thank you for following up.
This same code works properly on our end. Are you sure that you added it correctly in the functions.php file? Please post the login details in the private field so that we could test it.
Best regards,
IsmaelSeptember 13, 2021 at 6:13 am #1320628This reply has been marked as private.September 13, 2021 at 7:42 am #1320640Hi,
Thank you for the info.
It is not working because you did not select any image in the Masonry Gallery element. Please try to edit the masonry element, edit the gallery and select the images manually.
Best regards,
IsmaelSeptember 13, 2021 at 8:21 am #1320652Hmm… I see, but we would like to display all images from mediathek. When new images are uploaded they should be visible immediately.
Best regards
Tobias
September 17, 2021 at 7:43 am #1321337Hi,
Sorry for the delay. Try to replace the filter with the following code to sort the masonry items by date in descending order.
add_filter("avia_masonry_entries_query", function($query) { $query["orderby"] = "date"; $query["order"] = "DESC"; return $query; }, 10, 1);
Thank you for your patience.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.