WordPress.org

Make WordPress Core

Opened 18 months ago

Last modified 18 months ago

#47493 new defect (bug)

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

Reported by: 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
18 months ago

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