I have two links: Products and News.
When i click on Products or News, it returns me an archive page that contains some posts, when i click on a post it returns me a single page of this post.
In the menu I use this code on <li>
to add a class called active if the page is home:
<li<?php if(is_home()) {?> class="active"<?php } ?>>
But i dont know how to do it when I have two archive pages and two singles pages.
If i use if( is_archive() || is_single() )
it'll add class on both menu itens.
Some help would be appreciated.
is_archive
andis_single
should be mutually exclusive. I'd suggest you post more code. Why are you not usingwp_nav_menu
?wp_nav_menu
, it add class current but doesnt add this class on Products nor News.wp_nav_menu
and see the answer by @BradDalton.