Example / How To: Show related posts based on common tags in different taxonomies

Say you’re looking at CPT: cars with a taxonomy of car_tags and the current post has a tag of bmw

And you want to list posts from CPT: bikes with the same bmw tag in a taxonomy of: bike_tags

Pass variables to the template like this:

[template name=tag-intersect t-current='car_tags' t-rel='bike_tags' cpt-rel='bikes' vpage=5]

Name this template: tag-intersect

<Note> create an array of tags for the current post</Note>

<List name=tag_array>
 <Loop taxonomy='{Get local=t-current /}' post=current>
   <Item><Field name /></Item> 
 </Loop>
</List>

<Loop type='{Get local=cpt-rel /}' taxonomy='{Get local=t-rel /}' terms='{Get list=tag_array /}' paged="{Get local=vpage}">
  <div style="margin-top: 1em; margin-bottom: 2em;">
    <Field name />
  </div>
</Loop>
<PaginateButtons scroll_top=true />
3 Likes