Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#47493 new defect (bug)

Meta Query Sorting with relation => OR not behaving as expected

Reported by: tcaneeaglepub Owned by:
Priority: normal Milestone: Awaiting Review
Component: Query Version: 4.8.2
Severity: normal Keywords:
Cc: Focuses:

Description

When sorting on multiple meta query clauses with the default AND relation the sorting works as expected. When sorting with an OR relation the sorting does not function as expected.

'meta_query' => array(
	//'relation' => 'OR',// when turning this on the sorting does not work..
	'cornerstone_clause' => array(
		'key' => '_yst_is_cornerstone',
		'compare' => 'EXISTS',
		'type' => 'BINARY',
	),
	'count_clause' => array(
		'key' => 'erp_post_views_count',
		'compare' => '>',
		'value' => 0,
		'type' => 'NUMERIC',
	),
),
'orderby' => array(
	'cornerstone_clause' => 'DESC',
	'count_clause' => 'DESC',
),

The idea of the query is to first show any posts that contain '_yst_is_cornerstone' and sort the remaining by 'erp_post_views_count'.

Change History (1)

#1 @SergeyBiryukov
7 years ago

  • Component General → Query
Note: See TracTickets for help on using tickets.