itoigawaのブログ
2012-05-12
カスタム投稿タイプの投稿に属するタームを取得する
$terms = wp_get_post_terms( get_the_ID(), 'works', array( 'orderby'=>'name', 'order'=>'DESC' ));
if ($terms){
foreach ( $terms as $term ):
$arterm[] = $term->slug;
endforeach;
}
タームから関連する投稿を取得する
query_posts(
array(
'post_type' => 'portfolio',
'posts_per_page' => 12,
'post__not_in' => array($post->ID),
'tax_query' => array(
array(
'taxonomy'=>'works',
'terms'=>$arterm,
'field'=>'slug',
'operator'=>'IN'
),
'relation' => 'AND'
)
)
);
タームなどの言葉の使い方が違ってるかもしれないです。