Make WordPress Core

Opened 6 years ago

Last modified 5 years ago

#44695 new defect (bug)

WP_Term_Query unexpected 'orderby' behaviour. — at Initial Version

Reported by: williampatton's profile williampatton Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.7
Component: Query Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

I expected that orderby would behave in a similar way with wp_term_Query as it does on other query classes but it seems that meta_value_date and possibly some others is unsupported. Additionally meta_type doesn't function as expected either.

These args:

$args = array(
	'taxonomy'      => 'issues',
	'number'        => 5,
	'meta_key'      => 'issue_date',
	'meta_type'     => 'DATE',
	'orderby'       => 'meta_value_date',
);

Result in this query that has disregarded both meta_type and orderby in it's generation:

SELECT DISTINCT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_termmeta ON ( t.term_id = wp_termmeta.term_id ) INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('issues') AND tt.count > 0 AND ( wp_termmeta.meta_key = 'issue_date' ) ORDER BY t.name ASC LIMIT 5

Could we get similar support for same named keys in WP_Term_Query as we have in other queries?

Change History (0)

Note: See TracTickets for help on using tickets.