Conditional Related Posts in Bricks


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:

This is a Pro members-only tutorial.

To get full access, login below or sign up for a Pro Account

Leave your comment