Highlight the current post’s tags using CSS
The idea is to show all the tags used on the site and then add a CSS class to the tags that are used in the current post. This class can then be styled as required. In this example, the active
class is added to the current post’s tags.
In this example, the post-tags are shown in a list using the <li>
tag, but this can be changed to any HTML.
|
|
Note: In Line 5, it is assumed that get_the_ID()
will return the current post’s ID because this code is run within the WordPress Loop. If it is not, this should be replaced with another way to get the current post’s ID.