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