May be I didn’t explain well enough.
I need to query all my articles that belong to the same magazine (let’s say number 1)
that belong to a specific custom post type (articles) and are publish.
And I really need to order by article number. 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!!!