How to extend tag and category “Related Posts” query to custom post_type if the first 2 terms have no posts
You should take your third query outside the first // We will now run the second query if $count is less than $total_posts if ( $count < $total_posts ) { condition. You should also need to update the counter after the second query and rebuild the list to exclude posts already in the array of … Read more