Highlight archive link on single.php

As your links are generated by get_archives_link(), this is the place where you have to look. Doing so, by inspecting the source , you will notice that get_archives_link() – itself – doesn’t give you the possibility to add a CSS class to make the highlighting happen.

There is of course the filter hook get_archives_link – or see the source – which could be used to do this. But as you can see, the only information available is the complete link html output – $link_html – which pretty much forces you to do some RegEx to extract the URL and then check on that and if it fits add a class to the output. This is a way to do it and you will find information on here or out there how to do it.

But, if we are honest, it is not great, because who actually wants to do RegEx’s all the time – it is just not really desirable. So personally it would make my_own_archives_link() function, there you can implement the possibility to add classes for highlighting according to your needs.