Title: Using if else statements
Last modified: August 19, 2016

---

# Using if else statements

 *  Resolved [Richard Brown](https://wordpress.org/support/users/cregy/)
 * (@cregy)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/using-if-else-statements/)
 * Hi All
 * At this site:
    [Lostwithiel](http://www.lostwithiel.eu/category/businesses/shops/)
   You can see that I have used the archive.php to create a child menu when selecting
   the adult category.
 * However, what I also want to do is when selecting a child of a category:
    [Lostwithiel Restaurants](http://www.lostwithiel.eu/category/businesses/eating-out/restaurants/)
   As I have done here I also want to display the parent category similar to a breadcrumb.
 * Trouble is the way I am doing it involves hard-coding every category into the
   if and else statements:
 *     ```
       <?php /* If this is a Eating Out Category */ } elseif (is_category('5')) { ?>
       <div id="eatingout">
       <h3>Eating Out</h3>
       <p>Enjoy your food? Then Lostwithiel has a lot to offer. Recently a winner of a good food competition.</p>
       <div class="subcategories">
       <?php wp_list_categories("child_of=5&title_li=$listtitle"); ?>
       </div>
       </div>
   
       <?php /* If this is a Restaurants Category */ } elseif (is_category('10')) { ?>
       <div id="eatingout">
       <h3>Restaurants</h3>
       <p>Other sections in Food and Drink:</p>
       <div class="subcategories">
       <?php wp_list_categories("child_of=5&title_li=$listtitle"); ?>
       </div>
       </div>
       ```
   
 * Not very dynamic and quite lengthy in terms of shops and services. They will 
   end up with over 50 cats.
 * Any ideas how I could improve this idea please?
 * Thanks
 * Rich

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

 *  Thread Starter [Richard Brown](https://wordpress.org/support/users/cregy/)
 * (@cregy)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/using-if-else-statements/#post-706519)
 * Hi
 * I have installed a breadcrumb trail which will help navigation but if there are
   any other suggestions they will be much appreciated.
 * Thanks.
 * Rich
 *  Thread Starter [Richard Brown](https://wordpress.org/support/users/cregy/)
 * (@cregy)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/using-if-else-statements/#post-706638)
 * Hi
 * Answered at this post:
    [http://wordpress.org/support/topic/159810?replies=6#post-703162](http://wordpress.org/support/topic/159810?replies=6#post-703162)
 * Rich

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

The topic ‘Using if else statements’ is closed to new replies.

## Tags

 * [else](https://wordpress.org/support/topic-tag/else/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [templating](https://wordpress.org/support/topic-tag/templating/)

 * 2 replies
 * 1 participant
 * Last reply from: [Richard Brown](https://wordpress.org/support/users/cregy/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/using-if-else-statements/#post-706638)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
