term_id; }, $categories); $args = array( 'category__in' => $category_ids, 'post__not_in' => array($current_post_id), 'posts_per_page' => 3, ); $related_posts_query = new WP_Query($args); if ($related_posts_query->have_posts()) { echo '
'; wp_reset_postdata(); } } ?>