ordering fallback

This commit is contained in:
Mike Jolley 2019-02-01 13:13:41 +00:00
parent 3697f5104a
commit b64fad99f5
1 changed files with 3 additions and 2 deletions

View File

@ -96,8 +96,9 @@ function wc_terms_clauses( $clauses, $taxonomies, $args ) {
// For sorting, force left join in case order meta is missing.
if ( ! empty( $args['force_menu_order_sort'] ) ) {
$clauses['join'] = str_replace( "INNER JOIN {$wpdb->termmeta} ON ( t.term_id = wp_termmeta.term_id )", "LEFT JOIN {$wpdb->termmeta} ON ( t.term_id = {$wpdb->termmeta}.term_id AND {$wpdb->termmeta}.meta_key='order')", $clauses['join'] );
$clauses['where'] = str_replace( "{$wpdb->termmeta}.meta_key = 'order'", "{$wpdb->termmeta}.meta_key = 'order' OR {$wpdb->termmeta}.meta_key IS NULL", $clauses['where'] );
$clauses['join'] = str_replace( "INNER JOIN {$wpdb->termmeta} ON ( t.term_id = wp_termmeta.term_id )", "LEFT JOIN {$wpdb->termmeta} ON ( t.term_id = {$wpdb->termmeta}.term_id AND {$wpdb->termmeta}.meta_key='order')", $clauses['join'] );
$clauses['where'] = str_replace( "{$wpdb->termmeta}.meta_key = 'order'", "{$wpdb->termmeta}.meta_key = 'order' OR {$wpdb->termmeta}.meta_key IS NULL", $clauses['where'] );
$clauses['orderby'] .= ', t.name';
}
return $clauses;