ID ); $related_post_count = get_theme_mod( 'pixigo_related_post_count', 2 ); // To avoid negative related post count. $related_post_count = ( $related_post_count > 0 ) ? $related_post_count : 2; if ( $categories ) : $category_ids = array(); foreach ( $categories as $individual_category ) { $category_ids[] = $individual_category->term_id; } $args = array( 'category__in' => $category_ids, 'post__not_in' => array( $post->ID ), 'posts_per_page' => $related_post_count, 'ignore_sticky_posts' => 1, ); $related_posts_query = new WP_Query( $args ); if ( $related_posts_query->have_posts() ) : ?>