How to show related nodes in a block with Views 3 and Drupal 7 using taxonomy terms

Question: 

I want to list nodes related to the currently viewed node based on their taxonomy terms using Drupal 7 and Views 3.

I want to show all the related nodes (using the same taxonomy term) in a block.

How do I do this?

Answer: 

This question is asked very frequently because Drupal's Similar by Terms module doesn't seem to work correctly, and you can easily achieve the same functionality to display a block of related nodes based on their taxonomy by using Views 3.

Follow these steps to create a block of related nodes based on their taxonomy terms using Views 3:

  1. Create a new block view.
  2. Add some fields to the view. Can be title, body, whatever. You can even use node teasers.
  3. Click the Contextual Filter.
  4. Add the following filters:
    • "Content: Has taxonomy term ID (with depth)"
    • "Content: Has taxonomy term ID depth modifier"
  5. Configure this filter:
    When the filter value is NOT available  » Provide default value » Type: Taxonomy Term ID from URL » "Load default filter from node page, that’s good for related taxonomy blocks."
    At this stage you can select to limit terms by vocabulary and select the vocabulary you want to use for that filter.
  6. Now your related nodes block is working you might want to exclude the currently open node from the list of related nodes. To do that add another contextual filter and select Content:Nid as filter.
    Under When the filter value is NOT available select Provide default value and select type: Content ID from URL. Scroll down to MORE and check the Exclude box. This will remove the current node from the results.
  7. After saving this filer we need to move it to the top position in the filter list. To do this click rearrange under Contextual filters and move the Content: Nid to the top.
  8. Save the view.
  9. Enable your block at /admin/structure/block to display related nodes on selected node types and/or URLs.
Tags: