Skip to main content

Drupal 8/9/10: Showing Other Content by the Current Author

Learn how to create a block that shows other content by the same author

Books by CS Lewis

Introduction

For this article we used:

  • Drupal 9.5.7

Previously we wrote about:

In this article you'll learn how to show a block of links to other articles by the same author, to be placed alongside Article nodes.

Step 1: Create a block view of Articles

  • Display type: block
  • Name: Articles by the same Author

1.1 Filters

  • Published: yes
  • Content type: Article

1.2 Sort criteria

  • Authored on (desc)

1.3 Contextual filter

  • Field: Content Authored by
  • When the filter value is not available:
    • provide default value: User ID from route context
    • Also look for a node and use the node author: yes

1.4 Add a second contextual filter

When displaying the block alongside an article, the title of that article would also appear in the block with all the other articles by the current author.

If, like us, you don't want this, you can add a second contextual filter to exclude the current article from the results shown in the block.

  • Contextual Filter name: ID (content)
  • When the filter is not available:
    • provide default value: Content ID from URL
  • More → select Exclude

Summary

To show a block of articles related by author, you don't need to install any additional modules:

  • create a view of Articles
  • add a contextual filter on the author id
  • add a second contextual filter to exclude the current article