Compare commits
3 Commits
79fff56a25
...
735a4c3038
| Author | SHA1 | Date | |
|---|---|---|---|
| 735a4c3038 | |||
|
|
37572b5a8a | ||
|
|
681e2ed152 |
@@ -300,17 +300,18 @@ final class Sort {
|
|||||||
foreach ($wp_query->query['tax_query'] as $tax) {
|
foreach ($wp_query->query['tax_query'] as $tax) {
|
||||||
if (!isset($tax['taxonomy'])) continue;
|
if (!isset($tax['taxonomy'])) continue;
|
||||||
if ($current_relationship['taxonomy'] != $tax['taxonomy']) continue;
|
if ($current_relationship['taxonomy'] != $tax['taxonomy']) continue;
|
||||||
$term_by = $tax['field'];
|
$term_by = $tax['field'] ?? 'term_id';
|
||||||
$term_id = $tax['terms'];
|
$term_id = $tax['terms'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if ($current_relationship['taxonomy'] === 'category' && isset($wp_query->query['category_name'])) {
|
} else if ($current_relationship['taxonomy'] === 'category' && isset($wp_query->query['category_name'])) {
|
||||||
$term_id = $wp_query->query['category_name'];
|
$term_id = $wp_query->query['category_name'];
|
||||||
}
|
}
|
||||||
if (empty($term_id)) break;
|
if (is_array($term_id)) $term_id = array_values($term_id)[0];
|
||||||
|
if (empty($term_id)) return;
|
||||||
|
|
||||||
$term = get_term_by($term_by, $term_id, $current_relationship['taxonomy']);
|
$term = get_term_by($term_by, $term_id, $current_relationship['taxonomy']);
|
||||||
if (!is_a($term, 'WP_Term')) break;
|
if (!is_a($term, 'WP_Term')) return;
|
||||||
|
|
||||||
$wp_query->set('meta_key', "ogre-sort_{$current_relationship['taxonomy']}_{$term->term_id}");
|
$wp_query->set('meta_key', "ogre-sort_{$current_relationship['taxonomy']}_{$term->term_id}");
|
||||||
$wp_query->set('orderby', 'meta_value_num');
|
$wp_query->set('orderby', 'meta_value_num');
|
||||||
|
|||||||
Reference in New Issue
Block a user