I have a nav <li>
item where I add a page_active
CSS class when a submenu page is visited. This works all OK when one of the pages is visited, but I can't get it to add the class when the second submenu page is visited.
With the code below if you visit the 'Our Team' submenu page the 'About' parent menu item has the CSS class page_active
added.
<li class="td menu-item menu-item-2 underline-about <?php if (is_page('Our-Team')){echo "page_active";};?>">ABOUT
<ul class="submenu about-submenu">
<li class="submenu-item submenu-item-1"><a class="tl submenu-link" href="<?php echo esc_url(home_url('/our-team'));?>">Our Team</a></li>
<li class="submenu-item submenu-item-2"><a class="tl submenu-link" href="<?php echo esc_url(home_url('/representation'));?>">Representation</a></li>
</ul>
</li>
However because I want the CSS class to be added to the parent <li>
item when you visit either submenu page, I thought I could do this by adding a simple ||
or operator in the is_page()
function, but this doesn't work. I've tried the code below in the parent <li>
item.
<?php if (is_page('Our-Team || 'Representation')){echo "page_active";};?>
How would i get it to add the 'page_active' class to the parent menu item on either/both pages?