Are you looking to display related posts for your custom post type in WordPress? This is a great way to keep your readers engaged and interested in your content. By showing them posts that are related to the one they are currently viewing, you can encourage them to stay on your website longer and explore more of what you have to offer.
One easy way to accomplish this is by using the Post Listing block from the Nexter Blocks. This powerful block makes it easy to display related posts for your custom post type, and you can customise the look and feel to match your website’s design.
To check the complete feature overview documentation of the Nexter Blocks Post Listing block, click here.
Requirement – This block is a part of the Nexter Blocks, make sure its installed & activated to enjoy all its powers.
To display related posts for a custom post type, you first need to have a custom post type with a corresponding taxonomy and a few posts assigned to it.
You can use any CPT plugins, such as Advanced Custom Fields (ACF), Custom Post Type UI, Pods, Custom post types etc. to create your custom post type and taxonomy.
For example, we have a custom post type called Books and taxonomy Book Authors. We want to show related posts based on the book author’s name on the book single post page.
To create the single post template for the custom post type, you can use the free Nexter Builder.
To do this, from the Dashboard, go to Nexter Builder > Add New.
Add the template name, then scroll down to the Nexter Builder section, from the Layout, select Pages, and from Pages options, select Singular.
In the Singular 1 tab, keep Include selected in the Include/Exclude column. From the Conditional Rules dropdown, select your custom post type option. For instance, we’ll select All Books. Then publish the template.
Now once you have created the single post template, add the Post Listing block, and select Single Page Related Posts from the Post Listing Types section.
From the Select Post Type dropdown, select your custom post type. For instance, it is Books here.
Then in the Query tab, select your custom taxonomy from the Taxonomies dropdown, in our case, it is Book Authors.
Then select the appropriate style and layout from the Style and Layout, respectively.
Now you should be able to see related posts on a single post page based on your custom taxonomy.
Note: Make sure to use other single post blocks to ensure that your page content is displayed correctly.
You can fine-tune the settings and style from other options.
Also, check How to Show Related Post by Child Category in WordPress.