Style a link based on the tags of the post it links to
-
I have a custom post type and a custom taxonomy (I put post and tag in the title for simplicity). When I cross-link to one post in the body of another, I’d like the link to be styled based on the taxon that the linked post belongs to.
For example, say the custom taxon options are “good” and “bad”. When I link to a post that’s tagged “good”, I want the link to be highlighted in green. When I link a post tagged “bad”, I want the link highlighted in red. I want to figure out a way to do this automatically/programmatically, so that I *don’t* have to check the tags of a post before I link to it and manually add a css class to the link each time in order to style it. If I change the tags of a post, I’d like any internal links to that post to update their style to match.
Is there any way to retrieve the tags from a linked post while the page containing the link loads, in order to add a css class or otherwise alter the style of the displayed link?
- The topic ‘Style a link based on the tags of the post it links to’ is closed to new replies.