Creating a Related Post Section with GeneratePress can elevate your website’s user experience by offering relevant content to your audience. This tutorial walks you through the process using GeneratePress Pro and GenerateBlocks Pro, focusing on their powerful features like Dynamic Block Elements and query parameters.
Prerequisites
Please make sure you have the following installed and activated:
- GeneratePress (Pro)
- GenerateBlocks (Pro)
Setting Up the Element Section
- Navigate to
Appearance > Elements
in your WordPress dashboard. - Click on
Add New
and chooseHook
as the element type. - Name it “Related Posts Section” and set the hook location where you want the related posts to appear.
Creating a Post Content Template
- Navigate to
Elements > Post Content Template
. - Open the existing template or create a new one.
- Add a new heading by selecting the
Headline
block.- Set the heading level to H3.
- Type “You May Also Like These Posts…”
Adding Dynamic Content with Query Loop
- Navigate to
Elements > Post Content Template
. - Add a new block and search for
Query Loop
from GenerateBlocks. - Select a starter template, for example, a two-column layout.
- Set the number of posts to display to 2 or as desired.
Using Parameters for Dynamic Content
- Click on the
Query Loop
block. - Add a parameter and choose
Taxonomies
. - Select
Current Post Terms
to dynamically pull posts based on the current post’s taxonomy.
Excluding the Current Post
- Add another parameter in the
Query Loop
. - Choose
Exclude Posts
. - Select
Exclude Current Post
to ensure the current post is not displayed in the related posts section.
Randomizing the Displayed Posts
- Add another parameter in the
Query Loop
. - Choose
Order By
. - Select
Random
to randomize the posts displayed.
Related Post Section with GeneratePress – Conclusion
Creating a Related Post Section with GeneratePress is a straightforward process that can significantly improve your website’s user engagement. By using GeneratePress Pro and GenerateBlocks Pro, you can easily add dynamic, relevant content to your posts.