<div class="related-content">
<?php global $post; $tags = wp_get_post_terms( $post->ID, '$taxonomy' );
if ( $tags ) {
$first_tag = $tags[ 0 ]->term_id;
$args = array(
'post_type' => '$post-type',
'post__not_in' => array( $post->ID ),
'tax_query' => array(
array(
'taxonomy' => '$taxonomy',
'field' => 'term_id',
'terms' => $first_tag,
),
),
);
$my_query = new WP_Query( $args );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ): $my_query->the_post();?>
/* ================
Loop
===============*/
<?php endwhile;wp_reset_postdata();
}}
else {
echo '<p>* 暂无相关文章</p>';
}?>
</div>