Using if else statements
-
Hi All
At this site:
Lostwithiel
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
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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Using if else statements’ is closed to new replies.