'3', 'orderby' => 'rand', 'post__not_in' => array( get_the_ID() ), ); $related = wp_get_post_terms( get_the_ID(), 'category' ); $architecture_building_ids = array(); foreach( $related as $term ) { $architecture_building_ids[] = $term->term_id; } $architecture_building_post_args['category__in'] = $architecture_building_ids; $related_posts = new WP_Query( $architecture_building_post_args ); if ( $related_posts->have_posts() ) : ?>

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