我正在使用wordpress,我想用不同的分类法显示POST。
我在查询方面遇到了一些麻烦,我现在正在研究它2天..
我的查询:
SELECT wp_posts.ID, wp_posts.post_title, wp_posts.post_content, wp_posts.post_type,
wp_term_taxonomy.taxonomy, wp_terms.name
FROM wp_term_relationships, wp_term_taxonomy, wp_terms, wp_posts
WHERE wp_posts.post_type = 'dimsum'
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.term_taxonomy_id = wp_terms.term_id
AND wp_term_relationships.object_id = wp_posts.ID
这是控制台显示的内容: http://tinyurl.com/bnw2dot
但我想在我的wordpress主题上显示这样的东西:
需要按参考订购
Dimsum:
N1 - 蟹皇烧买 - 测试 - 测试(4) - 5.00
N10 - 晶莹鲜虾饺 - Har Kau - 蒸虾饺子(4) - 5.00
N11 - 蟹皇烧买 - Siu Mai - 蒸虾和猪肉饺子(4)--5.00
如果有人可以帮助我,我很绝望
答案 0 :(得分:0)
添加ORDER BY
并对订单字段感兴趣。
SELECT wp_posts.ID, wp_posts.post_title, wp_posts.post_content, wp_posts.post_type,
wp_term_taxonomy.taxonomy, wp_terms.name
FROM wp_term_relationships, wp_term_taxonomy, wp_terms, wp_posts
WHERE wp_posts.post_type = 'dimsum'
AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
AND wp_term_taxonomy.term_taxonomy_id = wp_terms.term_id
AND wp_term_relationships.object_id = wp_posts.ID
ORDER BY wp_term_taxonomy.taxonomy DESC //(OR ASC)