ID ); 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'=> $num, ); $the_query = new WP_Query($args); if( $the_query->have_posts() ): $posts = ''; endif; wp_reset_query(); return $posts; }//end if } elseif( $type == 'tag' && is_single() ){ $tags = wp_get_post_tags( $post->ID ); if ( $tags ) { $first_tag = $tags[0]->term_id; $args = array( 'tag__in' => $first_tag, 'post__not_in' => array( $post->ID ), 'posts_per_page'=>$num, ); $the_query = new WP_Query( $args ); if( $the_query->have_posts() ): $posts = ''; return $posts; endif; wp_reset_query(); }//end if } }