keeping current navigation highlighted
-
I think everytime there is a request like this it seems to be answered with a link to sites x, y and z – which offer solutions but not how to implement the solutions.
I was reading this artcile on A List Apart:
https://www.alistapart.com/articles/keepingcurrent/
Which teaches you how to keep the current id using php for your navigation menu and goes fairly indepth. I haven’t used it yet, but will consider it as I have yet to find an answer on how to do it with CSS that works in WordPress.
See with static pages it’s easy beacuse you place the html code for the navigation in one page, with WP you place it in the header of your theme, and this means that only one id would be highlighted.
It would be nice if someone could provide an actual guide and not just a link to list-o-matic and say check out those examples. What I think I am struggling with is trying to understand how the thing works both with pages and with templates.
Let’s say for example this is my code:
<div id="navigation">
<ul>
<li><a href="#">Page One</a></li>
<li id="currentpage"><a href="#">Page Two</a>
</li>
<li><a href="#">Page Three</a></li>
<li><a href="#">Page Four</a></li>
</ul>
</div>That goes in the header.php correct? Now in my css I will create a style for navigation, stick in an id for current and active and place those ids within the first page of the code at the top, beause when a user visits a site the header is called and therefore the first page is currently home.
What are the actual next steps? This is the bit that I find missing. How do you highlight your about page, your contact page and so on without creating multiple header.php files and then calling those? You don’t call the page in css, you call the attribute so if you create a page in WP, then you can’t assign an attribute to it if you use the same template for each page (which is the most likely).
Now say you have a template, you all the header.php but unless you create a seperate header.php you won’t be able to highlight that template as the current.
If someone has a better explanation and solution I’m all ears, but it’s something a lot of people (including myself) would like to learn. Has anyone thought of writing up a guide in the Codex because the implementation is slightly different to that of static pages, and I hope someone understands this and tries to explain it better.
Thanks in advance.
PS: If I’ve got it all wrong, let me know and explain where I should be looking and what I should be doing to get it working, because I’ve seen little in the way of workable examples, and people just giving and using standard non-highlighted navigation.
- The topic ‘keeping current navigation highlighted’ is closed to new replies.