Exclude category from custom taxonomy output
        Posted  
        
            by Nordin
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Nordin
        
        
        
        Published on 2010-06-07T14:53:47Z
        Indexed on 
            2010/06/07
            19:12 UTC
        
        
        Read the original article
        Hit count: 394
        
Hello,
I'm using the query below to output all links from a custom taxonomy. It outputs all posts that are tagged 'http' from the taxonomy 'words'. I would like to exclude some general categories from the output. So, fe. it only outputs links in the media and news categories. What would be the best way to achieve this.
$wp_query->request = "
SELECT DISTINCT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->posts.post_type = 'post' 
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = 'words'
AND $wpdb->terms.slug = 'http'
ORDER BY $wpdb->posts.post_date DESC
LIMIT $ppp OFFSET $offset";
$pagelinkposts = $wpdb->get_results($wp_query->request, OBJECT);
© Stack Overflow or respective owner