Forum
Set active navigation based on catSlug?
This might be a general coding question (if so happy to repost to stackoverflow) - but I have posted it here as it comes up many times in my perch websites.
Can I set the active class on my <li>
navigation based on the catSlug - and if so what is the best way to do this.
EG I have
<li><a href="index.php?cat=case">CASE STUDIES</a></li>
<li><a href="index.php?cat=news">NEWS</a></li>
<li><a href="index.php?cat=blog">BLOG</a></li>
and I want to set <li>
to active depending on whether (perch_get('cat') == 'case')
or 'news' or 'blog'
I know I should probably be using perch navigation - but is there a way to do this without?
https://galvininternational.com/blog/index.php?cat=case
Many thanks
You could do something like this:
Alex
Thank you SO much.
I had to move the php string inside the <li> to make my css work, but now its looking fab! Hooray!