WordPress
patterns/post-teasers-related-posts-dynamic.php
✔ Custom
- Use: the end of a single post, to keep readers moving to posts on the same subject.
- Not outside a single post, and not on sites whose posts carry no categories or tags.
- Source: posts that share terms with the one being read.
- Content: an optional topic, a heading and an optional subline; every post needs a landscape featured image in the same ratio as the others, since the teaser does not crop it, a hand-written excerpt, a category and tags; the query sets how many appear and the grid how many columns; one closing text link. Tag posts consistently; without shared terms it stays empty.
Figma
Docs
Block Variation
The related posts are generated using a block variation. It is located in the custom build at /block-variations/related-posts.php and modifies the Query Block.
If the current post belongs to a category, only posts sharing the same category are displayed within the loop. If no other post matches this criterion, nothing is displayed.
