• citizener

    (@citizener)


    I am quite new to php, but I have already seen the power that it holds. That being said, I think this should be an easy solution, I just don’t know the ins and outs of coding it yet.

    I am trying to use php to assign a class of “on” to the current page in my navigation system. I am doing this through the use of <?php $thisPage="pagenamehere"; ?>. Then, in my navigation menu, I apply the following…

    <li><a href="/"<?php if ($thisPage=="welcome") echo " class=\"on\""; ?>>Welcome</a></li>
    <li><a href="media/"<?php if ($thisPage=="media") echo " class=\"on\""; ?>>Media</a></li>
    <li><a href="thoughts/"<?php if ($thisPage=="thoughts") echo " class=\"on\""; ?>>Thoughts</a></li>
    <li><a href="answers/"<?php if ($thisPage=="answers") echo " class=\"on\""; ?>>Answers</a></li>

    I had this system working before I added WordPress, but now I can’t quite figure out the best way to implement it over. Ideally, I would like to use the same header.php file for all pages on the site. I hope this makes sense, but I can try to explain more if needed.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Navigation – Class=”On”’ is closed to new replies.