[wp-trac] [WordPress Trac] #29716: orderby for meta values is broken in 4.0
WordPress Trac
noreply at wordpress.org
Sun Sep 21 11:31:10 UTC 2014
#29716: orderby for meta values is broken in 4.0
-------------------------------+----------------------
Reporter: devarni | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Query | Version: 4.0
Severity: normal | Resolution: invalid
Keywords: reporter-feedback | Focuses:
-------------------------------+----------------------
Comment (by devarni):
I think it has something to do with the meta_query... this breaks the
order for unknown reasons in combination with the OR relation. This
behavior is new with 4.0. Removing the meta_query ordering is working as
expected.
This is the example query:
If the meta key "is_private" or does not exist or if the value is empty
the post should be queried.
This is not working with 4.0 anymore and the same time the orderby is not
working correctly.
$query_vars = array(
'post_type' => DG_POST_SLUG,
'meta_key' => DG_PREFIX . 'date',
'orderby' => array('meta_value_num' => 'DESC'),
'posts_per_page' => $posts_per_page,
'paged' => $page_no,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => DG_PREFIX . 'is_private',
'compare' => 'NOT EXISTS',
),
array(
'key' => DG_PREFIX . 'is_private',
'value' => '',
'type' => 'CHAR',
'compare' => '='
)
),
);
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29716#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list