How to add class dynamically from templates

I would like to add dynamic classes from templates to tags like , , which are defined in header.php and footer.php. WordPress do have body_class() and post_class() but they are limited to tag and corresponding respectively. Coming from twig which has a very easy way to do these things using {% set %} tag. Can something reusable function or filter be created in wordpress where I could add different classes from different templates to tags like , etc.

Read more here:: How to add class dynamically from templates

Leave a Reply

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