BuddyDev

Search

[Resolved] Order media by newest first (config switch?)

  • Participant
    Level: Master
    Posts: 279
    Richard Foley on #12942

    Using a fairly standard mediaPress install. My users want to see their newest images first, whenever they open a gallery. Seems reasonable.

    I don’t see anywhere to set this as an option in the admin settings eg; a newest/oldest first checkbox or similar, (which is where I’d expect it). Just to be clear, this is not a custom query/page or anything like that, I’m talking about just the standard profile gallery views. Perhaps I’m looking in the wrong place, or there’s another, simple, way to do this which I’ve not found yet.

    Helpful suggestions appreciated.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2348
    Ravi on #12956

    Hello Richard,

    Try the following code and let me know if it works or not.

    
    function buddydev_modify_media_order( $args ) {
    
         $args['orderby'] = 'modified';
    	
         return $args;
    }
    add_filter( 'mpp_main_media_query_args', 'buddydev_modify_media_order' );
    
    

    Thank You
    Ravi

  • Participant
    Level: Master
    Posts: 279
    Richard Foley on #12959

    Yay, perfect, and a nice demonstration of how to modify the MPP core behaviour from a local plugin too.

    Thanks Ravi!

    R.

  • Keymaster
    (BuddyDev Team)
    Posts: 21035
    Brajesh Singh on #12961

    It’s a bad idea. Will break the order for sorted gallery.

  • Keymaster
    (BuddyDev Team)
    Posts: 21035
    Brajesh Singh on #12963

    Ahh I see it now,
    Ignore my last reply. It’s good to go and will work. This filter fires way before we test for sorted gallery and sorted gallery will automatically override it.

    Thank you Ravi.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    Holly on #26179

    I want to use this reply to order the media by title on the gallery display in my WordPress site royalenfieldclub.nl (see https://leden.royalenfieldclub.nl/archief/fabriek-doc/5/#1930-1939).
    But in which file do I put the code and where in the file? (PS I don’t use Buddypress itself , just Mediapress).

    function buddydev_modify_media_order( $args ) {
    
         $args['orderby'] = 'title';
    	
         return $args;
    }
    add_filter( 'mpp_main_media_query_args', 'buddydev_modify_media_order' );

    greetings,
    Holly

  • Keymaster
    (BuddyDev Team)
    Posts: 21035
    Brajesh Singh on #26187

    Hi Holly,
    Thank you for using MediaPress.

    you may put the code in your theme’s functions.php

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    Holly on #26190

    When I put it in my theme’s functions.php I see no change in order on the document’s gallery page ( https://leden.royalenfieldclub.nl/en/archief/fabriek-doc/ ), which is also paginated ( [mpp-show-gallery id=2292 status:”loggedin” search_terms=’1940′] etc. ).

    What could be the cause of that?
    greetings,
    Holly

You must be logged in to reply to this topic.

This topic is: resolved