In the previous Posts Related by Current Post's Terms in Bricks tutorial, we showed how posts related to the current single post that have the same terms as the current post can be configured in a Bricks query loop.
That method is not reliable esp. in situations when the terms have commas and other special characters in them. This tutorial addresses this question a user asked in the comments section there:
I got this working on my page but for some reason it's not working for taxonomies that have commas in them, like "Cancer, Heart Attack, and Stroke" or "Dental, Vision, and Hearing" It displays fine for other Taxonomies without commas
This Pro tutorial provides the steps to use PHP query editor of a Bricks query loop to output x number of posts (of any post type) related to the current single post by a specified taxonomy.
After implementing the tutorial you could simply paste
return bl_get_related_posts_query();
in a query loop's PHP editor and sign code to output 5 posts that have the same category/categories as the current single post being viewed.
or for example,
return bl_get_related_posts_query( 'project', 'project-type', 7 );
to output 7 project
CPT posts that have the same project-type
custom taxonomy terms as the current single project being viewed.
Step 1
Add the following in child theme's functions.php
(w/o the opening PHP tag) or a code snippets plugin:
This is a BricksLabs Pro tutorial.
For full access login below or create your BricksLabs Pro account