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. https://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)
Viewing 1 replies (of 1 total)
- The topic ‘Highlight navigation’ is closed to new replies.