I'm trying to find a way to query posts on that have at least X tags in common with the current post. This example is close but I don't want to have to nominate which tags.
//List of tag slugs
$tags = array('SOMEHOW INCLUDE ALL TAGS');
$args = array(
'tag_slug__in' => $tags
//Add other arguments here
);
// This query contains posts with at least one matching tag
$tagged_posts = new WP_Query($args);
echo '<ul>';
while ( $tagged_posts->have_posts() ) : $tagged_posts->the_post();
// Check each single post for up to 3 matching tags and output <li>
$tag_count = 0;
$tag_min_match = 2;
foreach ( $tags as $tag ) {
if ( has_tag( $tag ) && $tag_count < $tag_min_match ) {
$tag_count ++;
}
}
if ($tag_count == $tag_min_match) {
//Echo list style here
echo '<li><a href="'. get_permalink() .'" title="'. get_the_title() .'">'. get_the_title() .'</a></li>';
}
endwhile;
wp_reset_query();
echo '</ul>';
Any help appreciated.