3, 'post__not_in' => array( $post->ID ), 'orderby' => 'rand', ); $cat_content_id = get_the_category( $post->ID ); if ( ! empty( $cat_content_id ) ) { $args['cat'] = $cat_content_id[0]->term_id; } $query = new WP_Query( $args ); if ( $query->have_posts() ) : ?>