Change default order

This topic contains 3 replies, has 4 voices, and was last updated by  Adrian Kinloch 9 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11836

    Hi,

    the admin’s list currently shows posts from old to latest by default but I would like to reverse it (order by desc). I know there is a button which would do it for me, but the preference doesn’t save. You have to reorder it every time you enter the page (wp-admin/edit.php?post_type=event).

    I managed to change it via the code but this is not effective way because I will have to change it when there’s a new update.

    So I wanted to ask you if you could add a selection to plugin’s settings to choose a default order.

    Here’s a code which does the magic

    includes/event-organiser-archives.php – line 535

    eventorganiser_is_event_query( $query, true ) ){
            //If no orderby is set, but we are querying events, return the default order for events;
            $orderby = " {$wpdb->eo_events}.StartDate DESC, {$wpdb->eo_events}.StartTime DESC";
    }
    return $orderby;

    Thanks,
    Mark

    Marek Zelezny
    #11840

    WordPress in general doesn’t remember sort order (see this very old trac ticket). However I’ll consider using a cookie for remembering the user’s selection. I don’t want to add an option for this as the aim is to keep the settings pages clutter-free and so easier to use.

    Alternatively a screen option could work.

    Stephen Harris
    #13311

    Hi, I wanted to do the same thing, and you can override the filter with another filter by putting this in your functions.php :

    add_filter('posts_orderby','my_eventorganiser_sort_events',20,2);
    function my_eventorganiser_sort_events( $orderby, $query ){
        global $wpdb;
        if( empty($query->query_vars['orderby']) ){
            if( eventorganiser_is_event_query( $query, true ) ){
                $orderby = " {$wpdb->eo_events}.StartDate DESC, {$wpdb->eo_events}.StartTime DESC";
            }
        }
        return $orderby;
    }
    Sylvie Clement
    #15313

    yep — could really do with the same thing. was assuming the pro-version i purchased would have had this as a simple toggle option, but alas no. thanks Sylvie.

    Adrian Kinloch
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.