Wordpress从自定义的帖子类型和自定义术语中获取所有附件

时间:2013-02-12 13:19:28

标签: php wordpress taxonomy wpdb

我拥有自定义帖子类型的所有附件,很好,但现在我还想要自定义术语的附件。

我使用自定义术语“架构”尝试了此查询:

global $wpdb;

$query = "select p1.*
    FROM {$wpdb->posts} p1, {$wpdb->posts} p2        
    WHERE p1.post_parent = p2.ID         
    AND p1.post_mime_type LIKE 'image%'
    AND p2.post_type = 'gallery'
    AND {$wpdb->posts}.terms.slug = 'architecture'        
    AND p2.post_status = 'publish'
    ORDER BY p1.post_date DESC";

$attachments = $wpdb->get_results($query); 
foreach ($attachments as $attachment) {
}

我做错了什么?

由于

0 个答案:

没有答案