Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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

    #1319938

    Hey 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,
    Ismael

    #1320025

    Hi 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, 3 months ago by Tobias.
    #1320330

    Hi,

    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,
    Ismael

    #1320502

    Hi Ismael,

    interesting, but unfortunately it does not work with it either. Do you have another idea?

    Best regards!

    Tobias

    #1320607

    Hi,

    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,
    Ismael

    #1320628
    This reply has been marked as private.
    #1320640

    Hi,

    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,
    Ismael

    #1320652

    Hmm… 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

    #1321337

    Hi,

    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

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