Title: Highlight navigation
Last modified: August 19, 2016

---

# Highlight navigation

 *  [rumlab](https://wordpress.org/support/users/rumlab/)
 * (@rumlab)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/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/](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)

 *  Thread Starter [rumlab](https://wordpress.org/support/users/rumlab/)
 * (@rumlab)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/highlight-navigation/#post-1630619)
 * 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.

## Tags

 * [list](https://wordpress.org/support/topic-tag/list/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [rumlab](https://wordpress.org/support/users/rumlab/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/highlight-navigation/#post-1630619)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
