'rand', 'return' => 'query', // Valid values are: 'query' (WP_Query object), 'array' (the arguments array) ) ); $related_args = array( 'post_type' => get_post_type( $post_id ), 'posts_per_page' => $related_count, 'post_status' => 'publish', 'post__not_in' => array( $post_id ), 'orderby' => $args['orderby'], 'tax_query' => array() ); $post = get_post( $post_id ); $taxonomies = get_object_taxonomies( $post, 'names' ); foreach ( $taxonomies as $taxonomy ) { $terms = get_the_terms( $post_id, $taxonomy ); if ( empty( $terms ) ) { continue; } $term_list = wp_list_pluck( $terms, 'slug' ); $related_args['tax_query'][] = array( 'taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term_list ); } if ( count( $related_args['tax_query'] ) > 1 ) { $related_args['tax_query']['relation'] = 'OR'; } if ( $args['return'] == 'query' ) { return new WP_Query( $related_args ); } else { return $related_args; } } $related = azurelo_get_related_posts( get_the_ID(), 3 ); $related_count = $related->found_posts; ?> = 2 && $related -> have_posts() ) : ?>

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