WordPress.org

Make WordPress Core

Opened 7 weeks ago

#42082 new enhancement

Support compare custom fields in WP_Meta_Query

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

Description

The syntax of WP_Meta_Query currently is limited to values you already know.

It's not possible to compare between two meta_values:

SELECT posts WHERE meta_value_one > meta_value_two

I propose allow compare two meta_fields. For example, the pseudocode above would be represented as a meta_query argument that looks like this:

<?php
array(
    'key'       => 'meta_value_one',
    'value'     => 'meta_value_two',
    'compare'   => '>',
    'type'      => 'META_VALUE'
),

A workaround can be found here and here hahaha.

Feedback is welcome.

Change History (0)

Note: See TracTickets for help on using tickets.