я использую такой код (не самый эффективный — так что модернизируйте):
<?php if(has_tag()) {
echo '<div id="relatedsets">';
$tempID = get_the_id();
$posttags = get_the_tags();
foreach($posttags as $tag) {
$temp = $tag->slug;
$tempname = $tag->name;
}
$query = new WP_Query( array( 'tag' => $temp,'order' => 'ASC' ));
$count = $query->found_posts;
if ($count > 1) {
echo '<p style="margin-top: 30px;margin-bottom: 12px;">Другие подборки на тему "'.$tempname.'":</p>';
echo '<ul style="margin-top:0;">';
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
if ($query->post->ID != $tempID) {
echo '<li><a href="'.get_the_permalink($query->post->ID) . '">' . get_the_title( $query->post->ID ) . '</a></li>';
} else {
echo '<li>' . get_the_title( $query->post->ID ) . '</li>';
}
}
wp_reset_postdata();
}
}
wp_reset_query();
echo '</ul></div>';
} ?>
у меня по этому коду идет вывод других записей с этой же меткой.