Custom Query with multiple meta values
-
I need to query all my articles (custom post type) that belong to the same magazine (another custom post type) let’s say, magazine number 1, and are publish.
And I really need to order by article number (custom meta box). So I have two custom meta_values:
_magazine-number for the filtering, and _article-number for the ordering.
this is the closest I could get:
SELECT pm.post_id FROM wp_yxgi_postmeta as pm INNER JOIN wp_yxgi_posts p ON p.ID = pm.post_id WHERE pm.meta_key = '_magazine-number' AND pm.meta_value = '1' AND p.post_status = 'publish' AND p.post_type = 'articulos'
The thing is, how can I order by ‘_article-number’ If I have already told the query that ‘meta_key’ is ‘__magazine-number’ ?
I have been dealing with this the whole day!!!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Query with multiple meta values’ is closed to new replies.