19th Nov '24
/
1 comment

Random Posts in the Same Category as the Current Single CPT Post in Bricks

Consider this scenario:

CPT: Practice Area
Taxonomy: Category (the built-in category taxonomy)

Requirement: When viewing single practice area CPT posts, show 4 random posts (the regular blog posts) that are assigned to the same category/categories as the current CPT.

Here’s how query loop can be set in Bricks to show related posts by a taxonomy’s terms:

Reference: Posts Related by Current Post’s Terms in Bricks.

If your category names have commas or other special characters, follow Related Posts by Taxonomy in Bricks instead for a more robust solution.

Get access to all 626 Bricks code tutorials with BricksLabs Pro

1 comment

  • Christopher Akins

    Inifintely easier than Oxygen. I was overthinking it. Thank you, Sridhar.

Leave a Reply to Christopher Akins (Cancel Reply)

 

Related Tutorials..

Pro
Querying Posts by ACF Date Sub Field in Bricks

Querying Posts by ACF Date Sub Field in Bricks

Updated on 17 Nov 2023. This Pro tutorial shows how we can set post__in query parameter of a query loop in Bricks to an array…
Categories:
Tags:
Pro
6 Random Featured Posts in Alphabetical Order in Bricks

6 Random Featured Posts in Alphabetical Order in Bricks

How to output x number of random posts with a specific meta value set, in Alphabetical order.
Categories:
Latest Featured Posts First in Bricks Query Loop (No Duplicates)

Latest Featured Posts First in Bricks Query Loop (No Duplicates)

In the Bricks Facebook group a user asks: We can use AI to help unfreeze our brains sometimes or at least have it write the…
Categories:
Related Posts by Author in Bricks

Related Posts by Author in Bricks

Querying posts on single posts by the author of the current post.
Categories:
How to Show Future Events in Bricks

How to Show Future Events in Bricks

One of the common requirements in WordPress is being able to filter the events (or could be posts of any post type) to only those…
Categories:
Pro
Current Post’s Terms in Bricks

Current Post’s Terms in Bricks

Updated on 15 Jan 2024 This Pro tutorial provides the steps to set up a grid of terms (like categories) that the current post is…
Pro
Top-level Pages and Children Bricks Query Loop

Top-level Pages and Children Bricks Query Loop

This Pro tutorial for Bricks users can be considered Part 2 or a variation of the earlier Bricks Query Loop for Top-level Parent Pages with…
Categories: