wordpress Q
- Started
- Last post
- 11 Responses
- forcetwelve
hi all. i am trying to get a menu issue sorted.
i'm using list_pages.
i have worked out how to make the active page highlighted – however when i click a post, and go to the posts single page the highlight disappears from the menu altogether.
has anyone got a fix for this?
- zr0
Something along the lines of this I imagine:
http://codex.wordpress.org/Categ…
- forcetwelve0
i don't follow how this relates to my problem. sorry. can anyone elaborate?
- acescence0
how do single posts relate to the pages? posts typically have nothing to do with pages, so it makes sense that nothing is highlighted.
- spraycan0
use php get superglobal on your wp header file to print the css of your choice
- zr0
I'm guessing you have a blog page within a larger site and want that page in the menu to be highlighted still, even though you're technically not on that page.
The technique I pointed you towards ^ is a means to add to the conditional logic of the menu highlighting... If the current post is within your defined category (all blog posts could be in the blog category) then the blog page will be highlighted in the menu.
- forcetwelve0
zr - thats right. i have the page 'projects' and then the posts are the individual projects.
so when i click the post/project the highlighting goes away.
- acescence0
there's no easy way to do what you're trying to do with list_pages, since posts aren't associable to pages. you either need to create a hook for list_pages and compare the current category to all of the pages (lots of regular expressions and not easy), or the simpler method would be to just hardcode your pages menu and use conditional tags to test if you're either on the portfolio page or within the portfolio category.
another option is to rethink how you've set things up and make the portfolio category page your main portfolio page, and again use conditional tags to load some other page content when you're on the category page.
- acescence0
oh yeah, conditional tags:
http://codex.wordpress.org/Condi…
- forcetwelve0
thx mate - i'll look into it.
- melq0
acescence has it exactly right.
What I will do is find out if the page has a parent. If so, then set a variable to the parent's value. If not, I set the variable to it's own value.
Then I use it to set a class, which is styled by the CSS.
In this example I also give the <body> tag an ID based on the post name:
http://pastebin.com/JtduEa3e
- forcetwelve0
wow - that's a bit over my head. i'll check it out though thanks.