Referring to posts in multiple categories

I have posts assigned to multiple categories, as in this example:

Post 1 > Cat A, Cat B
Post 2 > Cat A, Cat B, Cat C
Post 3 > Cat B, Cat C

The posts are accessed via category pages, and on the posts content.php template part I would like to show the name of the category page that the post was accessed from, for example:

Post 1 > accessed from Cat A > post shows ‘Cat A’
Post 1 > accessed from Cat B > post shows ‘Cat B’

However no matter what I’ve tried so far, the posts always show the name of the first (lowest ID number) category.

Is there a way to make the post template to dynamically show the relevant referring page/category?

Read more here:: Referring to posts in multiple categories

Leave a Reply

Your email address will not be published. Required fields are marked *