treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] How to display drop down results

  • Hello,
    I have been working on this for sometime now.. I have created two drop down list of some child categories. I want the user to be able to select on the the categories in the drop down list and it display all of the post within that category on a page.. I am using Word Press as a platform.

    Issues:

    1. I have yet to figure out how to get all the post within the selected category to be displayed on a page.

    2. Using the current code below, when I add a new child category, it does not display in the drop down like it should. Here is a link with a screen shot

    Any help or advice would be great.. Here is my code for the drop downs


     

    <div id="states">


    <p>Search by State</p>


    <select class="bg" name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
    <option value =<option value=""><?php echo esc_attr(__('Select State')); ?></option>
    <?php
    $categories= get_categories('orderby=id&&title_li&child_of=9');
    foreach ($categories as $category) {
    $option = '<option value="/category/archives/'.$category->category_nicename.'">';
    $option .= $category->cat_name;
    $option .= '</option>';
    echo $option;
    }
    ?>
    </select>

    </div>


    <div id="years">


    <p>Search by Year</p>


    <select class="bg" name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
    <option value =<option value=""><?php echo esc_attr(__('Select Year')); ?></option>
    <?php
    $categories= get_categories('orderby=id&&title_li&child_of=8');
    foreach ($categories as $category) {
    $option = '<option value="/category/archives/'.$category->category_nicename.'">';
    $option .= $category->cat_name;
    $option .= '</option>';
    echo $option;
    }
    ?>
    </select>



    </div>
  • Update.. I figured out the category being listed in the drop down problem.. Still need help with the displaying results.
  • figured it out.. thanks