ID; $catsArray = array(); $tagsArray = array(); foreach (get_the_category($postID) as $cat) { $catsArray[] = $cat->term_id; } foreach (wp_get_post_tags($postID) as $tag) { $tagsArray[] = $tag->term_id; } $args = array( 'post_type' => 'post', 'posts_per_page' => 3, 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'desc', 'fields' => 'ids', 'exclude' => array($postID), 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $catsArray, 'operator' => 'IN' ), array( 'taxonomy' => 'post_tag', 'field' => 'term_id', 'terms' => $tagsArray, 'operator' => 'IN' ) ) ); $relatedPosts = get_posts($args); if ( count($relatedPosts) <= 0 ) { return $content; } else { $relatedHTML = ''; return $content . $relatedHTML; } else : return $content; endif; } add_filter('the_content', 'blanco_lite_related_posts'); } ?>