Title: if Sub Categories exist?
Last modified: August 18, 2016

---

# if Sub Categories exist?

 *  [Ethics](https://wordpress.org/support/users/ethics/)
 * (@ethics)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/if-sub-categories-exist/)
 * Hey guys,
 * I currently have a few pages setup on my ‘blog’ and some have sub sections while
   others don’t.
 * Here’s the code I’m using…
 * <?php if ((is_page(2)) || (is_page(3)) || (is_page(4))) {include (‘sidebar_sub.
   php’); }
    else {include (‘sidebar_default.php’); } ?>
 * This is very unreliable to me, as I have to change the code every time I add 
   a new page to the site that uses sub sections.
 * ANOTHER HUGE problem I’m having with this code is when I click on one of the 
   sub sections in the main category the actual sub sections disappear from the 
   sidebar.
 * Can anyone point me in the right direction where I might be able to resolve this
   issue?
 * Thanks,
    Mario

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/if-sub-categories-exist/#post-655307)
 * _ANOTHER HUGE problem I’m having with this code is when I click on one of the
   sub sections in the main category the actual sub sections disappear from the 
   sidebar._
 * Since Pages don’t have categories… I don’t really get this “question”.
 *  Thread Starter [Ethics](https://wordpress.org/support/users/ethics/)
 * (@ethics)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/if-sub-categories-exist/#post-655308)
 * Let me try to clear it up…
 * Page 1
    –Page 4 –Page 5
 * Page 2
    –Page 6 –Page 7
 * Page 3
 * I have it setup so that the sub sections only show up in the sidebar when you
   are on Page 1 or 2. If you are on Page 3 you don’t get a sub menu option.
 * Now. The problem is when I click on Page 4-7. Since they don’t have sub sections,
   I get nothing in the sidebar.
 * What I want it to do is show the page 1 sub sections when you click on page 4
   or 5, so they don’t dissappear.
 * Hopefully thats a little easier to understand, sorry about the confusion.
 * Thanks,
    Mario

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘if Sub Categories exist?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Ethics](https://wordpress.org/support/users/ethics/)
 * Last activity: [18 years, 9 months ago](https://wordpress.org/support/topic/if-sub-categories-exist/#post-655308)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
