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

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