Highlight navigation
-
Hello all.
I know there are several posts on this, but I’m still a bit confused – hope someone can clarify:I have a sidebar for navigating my projects. http://rumlab.dk/blog/rumlab/
The code looks like this:<?php if (in_category('design')) { echo '<span class="current-category">Design</span>'; } else { echo 'Design'; } ?> <ul> <?php $IDOutsideLoop = $post->ID; global $post; $myposts = get_posts('category=3'); foreach($myposts as $post) : ?> <li <?php if(is_single() && $IDOutsideLoop == $post->ID) { echo " class=\"current\""; } ?>> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul> <?php if (in_category('architecture')) { echo '<span class="current-category">Architecture</span>'; } else { echo 'Architecture'; } ?> <ul> <?php $IDOutsideLoop = $post->ID; global $post; $myposts = get_posts('category=4'); foreach($myposts as $post) : ?> <li <?php if(is_single() && $IDOutsideLoop == $post->ID) { echo " class=\"current\""; } ?>> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>Found the code in the forums. Problem is, the current class is not applied in the repeated section.
I need to do this several times for different categories. Anyone?Thanks
Morten
Viewing 1 replies (of 1 total)
-
Well, removing
$IDOutsideLoop = $post->ID;
global $post;from the second
-
solved the problem with making the post titles current class,
but the second in_category still don’t do the job. I can see in
the documentation that you can do multiple in_category with elseif,
but it would seem, that solution would produce a lot of code?m
Viewing 1 replies (of 1 total)
The topic ‘Highlight navigation’ is closed to new replies.