Post Relationships Block

Hand-pick related posts for each post and show them in the order you choose.

Lauren Gray Avatar

Post Relationships Block lets you hand-pick related posts for each post and show them, in the order you choose, with a Query Loop. No algorithm guesses for you. You pick the posts.

Before you start

  • WordPress 5.8.3 or later
  • PHP 5.6 or later
  • The block editor, plus the core Query Loop block for displaying related posts

Install

  1. In your WordPress dashboard, go to Plugins → Add New Plugin.
  2. Click Upload Plugin.
  3. Choose the plugin zip file.
  4. Click Install Now.
  5. Click Activate.

How to use

There are two parts: choose the related posts for a post, then add a Related Posts Query Loop to show them.

  1. Open a post in the block editor.
  2. In the top toolbar, click the link icon to open the Add Related Posts sidebar.
  3. Type in the Search Posts field. Matching titles show up with their post IDs. Click Load more to see more results.
  4. Click a post to add it. It shows up in the list under the search field.
  5. Drag the handle next to a post to reorder the list. Click the trash icon (Delete related post) to remove one.
  6. Save or update the post. Your related posts are saved with it.

Search only looks at post titles and only finds content of the same post type you’re editing. Posts you’ve already added don’t show up in the results.

  1. In the block inserter, search for Related Posts and add it. This is a version of the Query Loop block.
  2. It starts with a post template (title and excerpt), pagination and a “no results” block. Change the inner blocks the same way you would in any Query Loop.
  3. Publish or update. The loop shows the posts you picked, in your order.

You can also put the Related Posts loop in a single-post template in the Site Editor, so it shows up on every post. Each post shows its own picks. The editor preview can’t show related posts while you’re editing a template, but they appear on the front end.

If a post has no related posts, the loop shows its “no results” content instead.

Developer reference

Coming soon: the hooks, filters and functions you can use with this plugin from your theme or a code snippet.

FAQs

Can I relate a post to a page or a different post type?

Not from the sidebar. Search only finds content of the same post type as the one you’re editing. The Related Posts loop also starts set to the current post type.