Within Wordpress header.php, I have
>
How do check to see if a specific class exists, and th
I have had the same problem as I created pages using different templates but a custom sub-menu needed to be the same on each pages.
I tried this one first what is failed
>
The extra classes was added to the body tag but when I run the error log then it was not in the classes array. So I was sure it was added later to the body tag.
This solution worked for me:
functions.php
$GLOBALS['extraBodyClass'] = '';
In the template file
- very first line in the template file
> - after the template name declaration
In the header.php file
$classes = get_body_class();
if($GLOBALS['extraBodyClass']){
$classes[] = $GLOBALS['extraBodyClass'];
}