[wp-trac] [WordPress Trac] #44695: WP_Term_Query unexpected 'orderby' behaviour.
WordPress Trac
noreply at wordpress.org
Wed Aug 1 21:21:45 UTC 2018
#44695: WP_Term_Query unexpected 'orderby' behaviour.
---------------------------+------------------------------
Reporter: williampatton | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.9.7
Severity: normal | Resolution:
Keywords: | Focuses:
---------------------------+------------------------------
Description changed by williampatton:
Old 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?
New 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?
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44695#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list