term_id; } } if(!empty($category_ids)){ $args = array( 'posts_per_page' => 3, 'category__in' => $category_ids, 'post__not_in' => array(get_the_ID()), 'order' => 'ASC', 'orderby' => 'rand' ); $related_posts = new WP_Query($args); if($related_posts->have_posts()): while ($related_posts->have_posts()) : $related_posts->the_post(); ?>