absint( get_theme_mod( 'bam_related_posts_count', '3' ) ), 'orderby' => 'rand', 'post__not_in' => array( get_the_ID() ), ); // Create an array of current term ID's $bam_tax_terms = wp_get_post_terms( get_the_ID(), $bam_related_posts_taxonomy ); $bam_terms_ids = array(); foreach( $bam_tax_terms as $tax_term ) { $bam_terms_ids[] = $tax_term->term_id; } // Use category ids if ( 'category' == $bam_related_posts_taxonomy ) { $bam_post_args['category__in'] = $bam_terms_ids; } // Use tag ids if ( 'tag' == $bam_related_posts_taxonomy ) { $bam_post_args['tag__in'] = $bam_terms_ids; } // Related posts query. $bam_related_posts = new WP_Query( $bam_post_args ); if ( $bam_related_posts->have_posts() ) : ?>