Forums

[resolved] Using if else statements (3 posts)

  1. cregy
    Member
    Posted 4 years ago #

    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

  2. cregy
    Member
    Posted 4 years ago #

    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

  3. cregy
    Member
    Posted 4 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic