How would I go about showing related posts on a single CPT?
To be more specific, in my example, I have a CPT called locations. It has a taxonomy called areas. On the single location post, it should show all the location posts that has the same area assigned to it.
Also - it would be ideal to exclude displaying the current location post (since they are already on that locations post)
@PolarRacing maybe I’m wrong, but I thought terms=current only worked when you’re in a taxonomy term loop already. Whereas in this case, the template is going to be on a post so I don’t think terms=current gets the terms from the current post.
I think you’d need to create a list of the taxonomy terms on the current post like this:
And then underneath that you could basically do what you’re suggesting where you’re looping through posts, but you reference the list in that terms parameter instead. Something like this:
I think that should do it. @tangiblerun I saw that you wrote exclude=current which might work, but when I check out the docs for the post loop, I’m seeing "exclude - Exclude by ID or name" without any mention of it accepting a value of current. So if it works that’s cool, but inventing stuff in L&L will often get you in trouble so it’s best to stick to only using tags/attributes/values that are mentioned in the documentation. For example, inventing attributes that aren’t written in the docs (like area=current) will never work.