[Gelöst] Change sort order of custom taxonomy archive
This support ticket is created vor 8 Jahre, 10 Monate. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
OK, this was helpful - would be great if there was a code snippet repository. Adding my input, just in case helps anyone else in the future too - sort order using a custom date field, code below worked for me.
//Order archive tax event by date
add_filter('pre_get_posts', 'order_tx_by_date');
function order_tx_by_date($q) {
if (($q->is_main_query()) && (is_tax('event-type'))) {
$q->set('orderby', 'meta_value');
$q->set('order', 'DESC');
$q->set('value', 'strtotime("00:00:00")');
$q->set('meta_key', 'wpcf-event-start-date');
}
return $q;
}
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.