0

i have this navbar markup below, what is the easiest way to manipulate my HTML or CSS, that when the user is in /contact.php then my <li> contact would change to <li class="active">Contact</li>.

<ul>
<li class="active"> HOME </li>
<li> CONTACT</li>
</ul>

im not sure if my logic is correct. but this is what im thinking

if(isset($_GET) == '.../contact.php') { 
    // change Markup here
}

also, please be informed that im using wordpress. there might be some wordpress ways i might not be aware of ..

3 Answers 3

1

I have found a link for you that might help, CMS systems like Wordpress of joomla work a little differently

http://wordpress.org/support/topic/adding-active-class-to-active-menu-item

please let me know if there is anything.

Sign up to request clarification or add additional context in comments.

Comments

1

I would like to know if you are using wp_nav_menu. If you do then you would not need to manually code the menu.

With regards to highlighting of current selected menu item and other features, I always refer to how twentythirteen theme handles it. See this style.css from theme, search for "4.2 Navigation", with that code, you can have highlight on current menu item plus other features you may need in the future.

Comments

0

Wordpress allready automatically adds current-menu-item on the menu item that is currently active, so your contact item in menu, when you are on the contact page allready has this class, provided that you are using wordpress native menu.

.current-menu-item {// your code}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.