在postmeta中可以说
- meta_key =' count'和meta_value =' 5'
- meta_key =' count'和meta_value =' 6'
- meta_key =' count'和meta_value =' 7'
醇>
现在我想获得所有帖子
WHERE meta_key = 'count'
AND orderby = 'meta_value_num'
AND order by ASC
注意:我不想使用query_posts或wp_query。只是自定义SQL查询。 提前致谢。
答案 0 :(得分:0)
试试这个:
SELECT wposts.*, postmeta.*
FROM wp_posts as wposts
LEFT JOIN wp_postmeta as postmeta ON (postmeta.post_id = wposts.ID)
WHERE wposts.post_type = 'post'
AND wposts.post_status = 'publish'
AND postmeta.meta_key = 'count'
ORDER BY postmeta.meta_value ASC
此处wp_
是数据库表的前缀,您可以将其替换为您自己的数据库表前缀。