Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#47493 new defect (bug)

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

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

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
5 years ago

  • Component changed from General to Query
Note: See TracTickets for help on using tickets.