WP_Queryに入れる条件がANDになっていてpost_typeとcategory両方設定させたらNOT FOUNDになるので、
SQLクエリ書いてみた。
select p.id
from
wp_posts p,
wp_term_relationships rel,
wp_terms t,
wp_term_taxonomy tax
where
post_type = 'カスタムポストのslug'
or (
t.slug = 'タグのslug'
and t.term_id = tax.term_id
and rel.term_taxonomy_id = tax.term_taxonomy_id
and p.id = rel.object_id
)
group by p.id
タグと投稿のつながりが遠いw
間に二つもテーブル挟むのね。。
まあともかく、これでIDが取得できるので、WP_Postのpost__inに入れればいい。
global $wpdb;
$post_ids = $wpdb->get_col( $wpdb->prepare( "
select p.id
from
wp_posts p,
wp_term_relationships rel,
wp_terms t,
wp_term_taxonomy tax
where
post_type = 'games'
or (
t.slug = 't_game'
and t.term_id = tax.term_id
and rel.term_taxonomy_id = tax.term_taxonomy_id
and p.id = rel.object_id
)
group by p.id
"));
$query_args = array( 'post__in' => $post_ids, 'post_type' => array('post', 'カスタム投稿のslug') );
$my_query = new WP_Query( $query_args );
こんな感じかな。