3, 'no_found_rows' => true, 'ignore_sticky_posts' => true, ); $current_object = get_queried_object(); if ( $current_object instanceof WP_Post ) { $current_id = $current_object->ID; if ( absint( $current_id ) > 0 ) { // Exclude current post. $qargs['post__not_in'] = array( absint( $current_id ) ); // Include current posts categories. $categories_detail = wp_get_post_categories( $current_id ); if ( ! empty( $categories_detail ) ) { $qargs['tax_query'] = array( array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $categories_detail, 'operator' => 'IN', ) ); } } } $the_query = new WP_Query( $qargs ); ?> have_posts() ) : ?>