同じタームの投稿を表示

情報を追記している場合はありますが、古い情報を訂正はしていませんので、公開年月日を参照してください。プラグイン・タグ、いずれもワードプレス・PHPのバージョン等によって動作しない場合もあります。

前にも書いたような気はしますが、メモとして改めて。

表示している投稿と同じタームの、その他の投稿(表示している投稿は除く)を表示。
タームが1つの場合

<?php $terms = wp_get_object_terms( $post->ID, 'taxonomy-name' );
if ( $terms && !is_wp_error( $terms ) ) {
	$thecat = array();
	foreach ( $terms as $term ) {
		$thecat = $term->slug;
		$thecatn = $term->name;
	}
} ?>
<?php
	$args = array(
		'post_type' => 'xxxx',
		'taxonomy-name' => $thecat,
		'posts_per_page' => 5,
		'post__not_in' => array($post->ID),
	);
	query_posts($args);
?>
<?php if (have_posts()) : ?>
            <h3><?php echo $thecatn; ?></h3>
<?php while (have_posts()) : the_post(); ?> ~

タームが複数の場合

<?php $terms = wp_get_object_terms( $post->ID, 'taxonomy-name' );
if ( $terms && !is_wp_error( $terms ) ) {
	$thecat = array();
	foreach ( $terms as $term ) {
		$thecat[] = '"' . $term->slug . '"';
	}
	$thecats = join( ',', $thecat );
} ?>
<?php
	$args = array(
		'post_type' => 'xxxx',
		'taxonomy-name' => $thecats,
		'posts_per_page' => 5,
		'post__not_in' => array($post->ID),
	);
	query_posts($args);
?>
<?php if (have_posts()) : ?> ~