yeah, it’s not easy. the root of it is that tags and categories are in the same table in the database.
this query will give you posts with both a specific category and tag slug. i use the slug as that’s what works for me, but you could change that to match on the name column…
<?php
global $wpdb;
$yourCategory = 'whatever';
$yourTag = 'whatever';
$querystr = "
SELECT p.* from $wpdb->posts p, $wpdb->terms t, $wpdb->term_taxonomy tt, $wpdb->term_relationships tr, $wpdb->terms t2, $wpdb->term_taxonomy tt2, $wpdb->term_relationships tr2
WHERE p.id = tr.object_id
AND t.term_id = tt.term_id
AND tr.term_taxonomy_id = tt.term_taxonomy_id
AND p.id = tr2.object_id
AND t2.term_id = tt2.term_id
AND tr2.term_taxonomy_id = tt2.term_taxonomy_id
AND (tt.taxonomy = 'category' AND tt.term_id = t.term_id AND t.slug = '$yourCategory')
AND (tt2.taxonomy = 'post_tag' AND tt2.term_id = t2.term_id AND t2.slug = '$yourTag')
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
if ($pageposts):
foreach ($pageposts as $post):
setup_postdata($post);
// do regular WordPress Loop stuff in here
endforeach;
else :
// nothing found
endif;
?>