array( $post->ID ), 'posts_per_page' => $limit, 'ignore_sticky_posts' => 1, 'post_type' => 'post' ); // by tags if( 'post_tags' == $related_by ) { $tags = wp_get_post_terms( $post->ID, 'post_tag' ); if ( $tags ) { $tag_ids = array(); foreach( $tags as $individual_tag ) $tag_ids[] = $individual_tag->term_id; $args['tax_query'] = array( array( 'taxonomy' => 'post_tag', 'field' => 'id', 'terms' => $tag_ids ) ); } } // by category elseif( 'post_category' == $related_by ) { $categories = wp_get_post_terms( $post->ID, 'category' ); if ( $categories ) { $category_ids = array(); foreach( $categories as $individual_category ) $category_ids[] = $individual_category->term_id; $args['tax_query'] = array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $category_ids ) ); } } $my_query = new wp_query( $args ); if( $my_query->have_posts()) { if( $title = get_setting( 'related_post_title' ) ) echo '