'post', 'post_status' => 'publish', 'posts_per_page' => $amount, 'ignore_sticky_posts' => true, 'post__not_in' => array($post->ID), 'orderby' => 'rand' ); if ($related_tax == 'cat') { $cats = get_the_category($post->ID); if ($cats) { $c = array(); foreach ($cats as $cat) { $c[] = $cat->term_id; } $args['category__in'] = $c; } } else if ($related_tax == 'tag') { $tags = get_the_tags($post->ID); if ($tags) { $t = array(); foreach ($tags as $tag) { $t[] = $tag->term_id; } $args['tag__in'] = $t; } } $q = new WP_Query($args); if ($q->have_posts()) { ?>