ID); if ($tags) { $ids = array(); foreach ($tags as $tag) { $ids[] = $tag->term_id; } $taxs [] = array( 'taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $ids ); } if ($taxs) { $related_args = array( 'tax_query' => $taxs, 'post__not_in' => array($post->ID), 'posts_per_page' => $limit ); $related_posts = new WP_Query($related_args); if ($related_posts->have_posts()): ?>

have_posts()): $related_posts->the_post(); ?>