This Pro tutorial provides the steps to output a section having the Related Posts element only if there is at least 1 related post for the current single post being viewed in Bricks.
We shall define a custom function that returns the count of posts that have the same tag or category as the current post and use that with Brick's echo dynamic data.
Then use that function to output a Section Template (having the "Related Posts" element) dynamically in the single Post Template if the count is greater than 0.
Step 1
Add the following in your child theme's functions.php or a code snippets plugin like WPCodeBox:
Sridhar Katakam is a Bricks enthusiast. He likes helping others by researching and solving WordPress-related problems and building websites.
Get access to all 633 Bricks code tutorials with BricksLabs Pro
Related Tutorials..
Pro
User Role Condition in Bricks
This Pro tutorial provides the steps to conditionally output elements depending on the currently logged-in user's role. Step 1 Create a section Template having the…
It is a common requirement to show posts (posts/CPT items) that belong to the same taxonomy (category/tag/custom taxonomy) as the current single post. This Pro…