Gutenberg Related Posts
Display posts related to the current post based on categories, tags, or custom taxonomies.
by blocklayouts · github.com/qarayahya/gutenberg-related-posts · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/qarayahya/gutenberg-related-posts/archive/refs/heads/main.zipReadme
Gutenberg Related Posts
Display posts related to the current post based on categories, tags, or custom taxonomies.
Description
Gutenberg Related Posts is a WordPress plugin that adds a "Related Posts" block variation to the core Query block. It intelligently displays posts related to the current post by matching taxonomies like categories, tags, or any custom taxonomies.
Features
- Smart Related Posts: Automatically finds posts that share taxonomies with the current post
- Flexible Taxonomy Selection: Choose specific taxonomies (categories, tags, custom taxonomies) or use all available taxonomies
- Built on Core Blocks: Extends the native WordPress Query block with a specialized variation
- Customizable Display: Use all the standard Query Loop features like grid layouts, pagination, and post templates
- Excludes Current Post: Automatically excludes the currently viewed post from related results
- Works on Single Posts: Designed specifically for singular post views
- No Coding Required: Simple interface integrated into the block editor
How It Works
The plugin registers a "Related Posts" variation of the Query block that:
- Detects the current post being viewed
- Retrieves the taxonomy terms associated with that post
- Queries for other posts sharing those terms
- Displays them using the flexible Query Loop pattern
Requirements
- WordPress 6.3 or higher
- PHP 7.4 or higher
- Gutenberg editor
Installation
- Upload the plugin files to the
/wp-content/plugins/gutenberg-related-postsdirectory, or install the plugin through the WordPress plugins screen. - Activate the plugin through the 'Plugins' screen in WordPress.
- In the block editor, insert the "Related Posts" block from the block inserter.
- Make sure to change the Query Type setting from "Default" to "Custom" in the block's settings sidebar.
- Customize the display and taxonomy filters as needed.
Usage
Adding a Related Posts Block
- Open the post/page editor
- Click the "Add block" button (+)
- Search for "Related Posts"
- Insert the block into your content
Configuring Taxonomy Filters
- Select the Related Posts block
- Open the Settings sidebar
- Navigate to the "Advanced" panel
- Use the "Filter by Taxonomies" field to select specific taxonomies
- Leave empty to automatically match all taxonomies from the current post type
Customizing the Display
The Related Posts block uses the standard Query Loop structure, so you can:
- Change the layout (grid, list, etc.)
- Adjust column count and spacing
- Add or remove post elements (title, excerpt, featured image, date, etc.)
- Configure pagination settings
- Style blocks with your theme's design system
Frequently Asked Questions
How are related posts determined?
Related posts are determined by matching taxonomy terms. If you select specific taxonomies (like "category" and "post_tag"), posts must share terms in ALL selected taxonomies (AND relation). If no taxonomies are selected, posts matching ANY taxonomy term will be shown (OR relation).
Can I use this with custom post types?
Yes! The plugin works with any post type and automatically detects the post type of the current post. It will only show related posts of the same post type.
Can I use custom taxonomies?
Absolutely. The plugin works with all public taxonomies, including custom taxonomies you've registered.
Does it work on archive pages or the blog homepage?
No, the plugin is designed specifically for single post views (singular templates). It needs a specific post context to find related content.
Can I customize the query further?
The Related Posts block inherits all the standard Query block controls, so you can adjust the number of posts, order, pagination, and more through the block settings.
License
This project is licensed under the GPL-2.0-or-later - see the LICENSE.txt file for details.
Changelog
1.0.0
- Initial release