Title: sidebar, conditional, category
Last modified: August 18, 2016

---

# sidebar, conditional, category

 *  Resolved [syncbox](https://wordpress.org/support/users/syncbox/)
 * (@syncbox)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/sidebar-conditional-category/)
 * I have categories that do not have posts. They only have descriptions. However,
   I want them to still display when the list of cats are displayed and a cat link
   is clicked – even if that category has no posts.
 * I can get this to happen, but the difference between clicking a cat link with
   posts versus no posts is what file is used to display content (category.php versus
   index.php)
 * What I haven’t figured out how to do is to get the same SIDEBAR content to display
   regardless of posts or no posts.
 * Now, I understand that I can use the “else {}” at the end of all my conditions
   to force display of particular content… but that is already being used.
 * any ideas?

Viewing 1 replies (of 1 total)

 *  Thread Starter [syncbox](https://wordpress.org/support/users/syncbox/)
 * (@syncbox)
 * [18 years, 8 months ago](https://wordpress.org/support/topic/sidebar-conditional-category/#post-637082)
 * Solved. Maybe not elegant, but working…
 * I changed the way my sidebar logic operates, using two levels of conditionals…
   so that I could say else {} twice, once only if_page() and at the end… without
   specifying whether page or category or single (basically, if using the index 
   page, since the only time it is ever used is when clicking one of the categories
   AND no posts exist)
 * <?php
    if (is_page()) { if($post->post_parent) { // page is a child wp_list_pages(‘
   depth=1&sort_column=menu_order&title_li=&child_of=’.$post->post_parent); echo(”);}
   elseif(wp_list_pages(“child_of=”.$post->ID.”&echo=0″)) { // page has children
   wp_list_pages(‘depth=1&sort_column=menu_order&title_li=&child_of=’.$post->ID);
   echo(”); } elseif (is_page(11)) { echo (‘ <p>stuff I want to show</p> ‘); } else{
   include (TEMPLATEPATH . ‘/file_i_want_to_show.php’); } } elseif (is_category()){
   echo ‘<h2>Text title here</h2>
    - ‘;
       wp_list_categories(‘title_li=&orderby=name&hide_empty=0&child_of=54&use_desc_for_title
      =0’); echo ‘
 * ‘;
    }
 * else {
    echo ‘<h2>Text title here</h2>
    - ‘;
       wp_list_categories(‘title_li=&orderby=name&hide_empty=0&child_of=54&use_desc_for_title
      =0’); echo ‘
 * ‘;
    } ?>
 * seems to work, though I am sure it is not elegant… so if there IS some way to
   test for using the index.php file (when clicking a cat list link where the cat
   has no posts) and then displaying specific sidebar content, I’m still all ears.
   meanwhile, I’ll mark this resolved, since it seems to work.

Viewing 1 replies (of 1 total)

The topic ‘sidebar, conditional, category’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [syncbox](https://wordpress.org/support/users/syncbox/)
 * Last activity: [18 years, 8 months ago](https://wordpress.org/support/topic/sidebar-conditional-category/#post-637082)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
