使用与wp_post,wp_term_relationships和wp_terms

时间:2017-11-30 14:28:48

标签: php sql wordpress

我有这个查询,当我执行它时,它会拉出3个单独的帖子,我根据他们的ID选择。唯一没有被拉动的是帖子缩略图。我试过用post_meta加入post_id等拦截拦截,但是没有成功

这是我到现在为止所得到的

SELECT *
FROM wp_posts p
#LEFT JOIN wp_postmeta pm ON (pm.post_id = p.ID AND pm.meta_value IS NOT NULL AND pm.meta_key = '_thumbnail_id')
#LEFT JOIN wp_postmeta pm ON (pm.meta_value = pm.post_id AND pm.meta_key = '_wp_attached_file' AND pm.meta_value IS NOT NULL)
#LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id AND pm.meta_key = '_wp_attachment_metadata'
LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID
LEFT OUTER JOIN wp_terms t ON t.term_id = r.term_taxonomy_id
WHERE p.ID in ('800','808', '569') 
  AND p.post_type in ('post', 'attachment')
  AND p.post_status = 'publish' 

带有hash-tags的是我失败的尝试,我在meta_key列上得到null值

0 个答案:

没有答案