Query between two meta keys

Update – it may be supported in a meta_query. I need more information – see below.

You can’t do it using a meta_query, it’s not supported.

Do you have data in meta_data fields? – WordPress queries will exclude posts where any of the orderby (or meta_query) fields is missing. WordPress adds a join condition to the SQL query to support the orderby or query fields, an inner join (a join which only includes posts with the join field.)

If the the orderby ‘inner join’ is the issue, if you need to include posts where this field may be missing, then you can filter the join and orderby clauses of the generated SQL

If you’re still not getting results, it would be useful to see the actual SQL that’s being generated. Add

<pre><?php echo your_query_object->request; ?></pre> 

to your template to display it, and add it to your question as an update.

Leave a Comment