Blog · Gutenberg
Related Posts block for WordPress
Shows posts sharing the category or tag with the current post via AJAX on the frontend.
Get Blockenberg
Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.
What it actually does
Shows posts sharing the category or tag with the current post via AJAX on the frontend.
Inspector panels on this block: Query, Display. Those titles come from index.js, not from a shared template.
Behavior controls: “Relation” options: Category, Tag, Both (and); “Layout” options: Grid, List, Carousel; “Image Ratio” options: 16:9, 4:3, 1:1, 3:2.
Where to find it
Gutenberg inserter → Blog → search “Related Posts” (block name `blockenberg/related-posts` in block.json). Style it in the sidebar after insert.
How to use Related Posts block for WordPress
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “Related Posts”, insert it. Category: Blog.
- Configure inspector controls that exist on this block. Open Query. Set “Relation”, “Number of Posts”, “Section Heading”, “Heading Tag”.
- Check the published page. The view script reads HTML data attributes: data-count, data-image-ratio, data-relation, data-show-date, data-show-excerpt, data-show-image. The block editor preview may not run the same view script.
Inspector controls from this block’s code
| Control | What the code does |
|---|---|
| Relation | Select control; the chosen value is saved on the block. Options: Category; Tag; Both (and). block.json default: category. Saved as `relation`. |
| Number of Posts | Numeric range control in the inspector. Range 1–12. block.json default: 3. Saved as `count`. |
| Section Heading | Text field in the inspector. block.json default: Related Posts. Saved as `heading`. |
| Heading Tag | Select control; the chosen value is saved on the block. block.json default: h3. Saved as `headingTag`. |
| Layout | Select control; the chosen value is saved on the block. Options: Grid; List; Carousel. block.json default: grid. Saved as `layout`. |
| Columns | Numeric range control in the inspector. Range 1–4. block.json default: 3. Saved as `columns`. |
| Gap (px) | Numeric range control in the inspector. Range 8–48. block.json default: 20. Saved as `gap`. |
| Show Image | On/off toggle in the inspector. On by default. Saved as `showImage`. |
| Show Excerpt | On/off toggle in the inspector. Off by default. Saved as `showExcerpt`. |
| Show Date | On/off toggle in the inspector. On by default. Saved as `showDate`. |
| Image Ratio | Select control; the chosen value is saved on the block. Options: 16:9; 4:3; 1:1; 3:2. block.json default: 16/9. Saved as `imageRatio`. |
| Card Radius (px) | Numeric range control in the inspector. Range 0–24. block.json default: 10. Saved as `cardRadius`. |
| Card Shadow | On/off toggle in the inspector. On by default. Saved as `cardShadow`. |
| Heading | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `headingTypo`. |
| Card Background | Color control in the inspector. block.json default: #ffffff. Saved as `cardBg`. |
| Card Border | Color control in the inspector. block.json default: #e5e7eb. Saved as `cardBorder`. |
| Placeholder Shimmer | Color control in the inspector. block.json default: #e5e7eb. Saved as `placeholderColor`. |
What the front-end script actually does
- The view script reads HTML data attributes: data-count, data-image-ratio, data-relation, data-show-date, data-show-excerpt, data-show-image.
- Submit/load uses fetch or wp.apiFetch on the published page, not the editor canvas.
When this is the right block
- Shows posts sharing the category or tag with the current post via AJAX on the frontend — that is the job of Related Posts, not a generic content block.
- Use it when you need the editor control labeled “Relation”, which exists on this block’s inspector.
- It matches pages about related, posts, similar.
- Inserter grouping: posts, magazines, and editorial WordPress pages.
Notes from the implementation
viewScript: this folder’s frontend.js is enqueued on the front end for this block.
FAQ
How do I add the Related Posts block in WordPress?
Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Related Posts”. It sits under Blog. After insert, open Query and set “Relation”, “Number of Posts”, “Section Heading”, “Heading Tag”.
What makes Related Posts different from other Blockenberg blocks?
Shows posts sharing the category or tag with the current post via AJAX on the frontend. Inspector labels on this block include “Relation”, “Number of Posts”, “Section Heading”, “Heading Tag”.
Is the Related Posts Gutenberg block free?
Yes. Related Posts ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.
Can I style Related Posts to match my theme?
Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Query, Display).
Related blog blocks
Article Series
Multi-part series navigator showing all articles with the current one highlighted and progress indicator.
Category Grid
Display WordPress post categories in a responsive grid with post counts, icons, descriptions, and rich styling options.
Post Carousel
A responsive carousel of posts with autoplay, arrows, and dots.
Post Grid
Display posts or custom post types in a responsive card grid. Powered by the built-in REST API endpoint.
Reading List
Curated book or article reading list with cover image, title, author, genre, star rating, read-status badge (Reading / Read / Want to Read / Recommended), description, and optional link.
Article Header
Rich editorial-style article/blog post header with category badge, headline, subheadline, author meta bar, and optional hero image.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert Related Posts from the Gutenberg inserter.