use taxonomy to refine search results

I’m a newbie to web developement, and I’m having a little problem with my WordPress Template!
here’s the page I’m talking about: Click to see page

In this page you can only see accomodations in a certain location (in this case Sevilla), and what I want to do is to add extra filters to the sidebar in a form of a checkbox, so the user could select the type of accomodation they want with certain facilities. For exemple if the user checks swiming pool in the sidebar and clicks submit, they’ll get the result with only accomodations with a swiming pool.

Read More

the sidebar comes in default with the Template and I know where to get to it, but I don’t know how to add those extra filters.
I was thinking about using taxonomy as filters, since we check the facilities the accomodation has from a list when we create a new one! is it posible to do such thing?

I hope I was clear enough and excuse my english
i would appreciate if anyone could give me any guidance or how to do it! thank you

<?php
/**
 * The sidebar containing the main widget area.
 *
 * If no active widgets in sidebar, let's hide it completely.
 *
 * @package WordPress
 * @subpackage BookYourTravel
 * @since Book Your Travel 1.0
 */
?>
<?php if ( is_active_sidebar( 'sidebar' ) ) : ?>
    <aside id="secondary" class="widget-area  lower" role="complementary">
        <ul>
        <?php dynamic_sidebar( 'sidebar' ); ?>
        </ul>
    </aside><!-- #secondary -->
<?php endif; ?>

That’s the code that appears in sidebar.php

Maybe that’s the sidebar code you wanted:

<!--sidebar-->
    <aside class="left-sidebar">
        <article class="refine-search-results">
            <form id="side-search" method="get" action="<?php echo $custom_search_results_page; ?>">
                <h2><?php _e('Refine search results', 'bookyourtravel'); ?></h2>
                <dl>
                    <input name="what" id="what" value="<?php echo $what;?>" type="hidden" />
                    <!--Price (per night)-->
                    <?php 

                        $price_range_bottom = of_get_option('price_range_bottom', '0');
                        $price_range_increment = of_get_option('price_range_increment', '50');
                        $price_range_count = of_get_option('price_range_count', '5');
                        $default_currency = strtoupper(of_get_option('default_currency_select', 'USD'));

                        if ($price_range_count > 0) {
                    ?>
                    <?php if ($what == 1 || $what == 2) { ?>
                    <dt><?php _e('Price (per night)', 'bookyourtravel'); ?></dt>
                    <?php } elseif ($what == 3) { ?>
                    <dt><?php _e('Price (per day)', 'bookyourtravel'); ?></dt>
                    <?php } elseif ($what == 4) { ?>
                    <dt><?php _e('Price (per person)', 'bookyourtravel'); ?></dt>
                    <?php } ?>
                    <dd>
                        <?php 
                            $bottom = 0;
                            $top = 0;
                            $out = '';
                            for ($i=0; $i<$price_range_count;$i++) { 
                        ?>
                        <div class="checkbox">
                            <input type="checkbox" id="price<?php echo $i+1; ?>" name="price[]" value="<?php echo $i+1; ?>" />
                            <label for="price<?php echo $i+1; ?>">
                            <?php                               
                                $bottom = ($i * $price_range_increment) + $price_range_bottom;
                                $top = (($i+1) * $price_range_increment) + $price_range_bottom - 1;                             
                                $out = $bottom;
                                if ($i == ($price_range_count-1)) {
                                    $out.=  ' <span class="curr">' . $currency_symbol . '</span> +';
                                } else {
                                    $out.= " - " . $top . ' <span class="curr">' . $currency_symbol . '</span>';
                                }

                                echo $out;
                            ?>
                            </label>
                        </div>
                        <?php } ?>
                    </dd>
                    <!--//Price (per night)-->
                    <?php } ?>

                    <?php if ($what == 1 || $what == 2) { ?>
                    <dt><?php _e('Accommodation type', 'bookyourtravel'); ?></dt>
                    <dd>
                    <?php for ($i = 0; $i < count($accommodation_types); $i++) { 
                        $accommodation_type = $accommodation_types[$i];
                    ?>
                        <div class="checkbox">
                            <input value="<?php echo $accommodation_type->term_id; ?>" type="checkbox" id="ch<?php echo $i + 1; ?>" name="acc[]" />
                            <label for="ch<?php echo $i + 1; ?>"><?php echo $accommodation_type->name; ?></label>
                        </div>
                    <?php } ?>
                    </dd>
                    <!--//Accommodation type-->

                                                    <!--User rating-->
                    <dt><?php _e('User rating', 'bookyourtravel'); ?></dt>
                    <dd>
                        <div id="slider"></div>
                        <input type="hidden" id="rating" name="rating" value="" />
                        <span class="min">0</span><span class="max">10</span>
                    </dd>
                    <!--//User rating-->
                    <?php } elseif ($what == 3) { ?>
                    <dt><?php _e('Car type', 'bookyourtravel'); ?></dt>
                    <dd>
                    <?php for ($i = 0; $i < count($car_types); $i++) { 
                        $car_type = $car_types[$i];
                    ?>
                        <div class="checkbox">
                            <input value="<?php echo $car_type->term_id; ?>" type="checkbox" id="cth<?php echo $i + 1; ?>" name="car_types[]" />
                            <label for="cth<?php echo $i + 1; ?>"><?php echo $car_type->name; ?></label>
                        </div>
                    <?php } ?>
                    </dd>
                    <!--//Accommodation type-->
                    <?php } ?>
                </dl>

                <div class="f-item datepicker">
                    <span><?php _e('Date from', 'bookyourtravel'); ?></span>
                    <div class="datepicker-wrap"><input type="text" placeholder="" id="from" name="from" /></div>
                </div>
                <?php if ($what == 1 || $what == 2 || $what == 3) { ?>
                <div class="f-item datepicker">
                    <span><?php _e('Date to', 'bookyourtravel'); ?></span>
                    <div class="datepicker-wrap"><input type="text" placeholder="" id="to" name="to" /></div>
                </div>
                <?php } ?>
                <?php if ($what == 1 || $what == 2) { ?>
                <div id="destination" name="destination" class="f-item">
                    <span><?php _e('Your destination', 'bookyourtravel'); ?></span>
                    <input type="text" placeholder="<?php _e('City, region, district or specific accommodation', 'bookyourtravel'); ?>" id="term" name="term" />
                </div>
                <?php } elseif ($what == 3) { ?>
                <div id="destination" name="destination" class="f-item">
                    <span><?php _e('Pick Up', 'bookyourtravel'); ?></span>
                    <input type="text" placeholder="<?php _e('I want to pick up car in', 'bookyourtravel'); ?>" id="term" name="term" />
                </div>              
                <div id="destination2" name="destination2" class="f-item">
                    <span><?php _e('Drop Off', 'bookyourtravel'); ?></span>
                    <input type="text" placeholder="<?php _e('I want to drop off car at', 'bookyourtravel'); ?>" id="term_to" name="term_to" />
                </div>              
                <?php } elseif ($what == 4) { ?>
                <div id="destination" name="destination" class="f-item">
                    <span><?php _e('Tour location', 'bookyourtravel'); ?></span>
                    <input type="text" placeholder="<?php _e('City, region, district or specific tour', 'bookyourtravel'); ?>" id="term" name="term" />
                </div>
                <?php } ?>
                <input type="submit" value="<?php _e('Search again', 'bookyourtravel'); ?>" class="gradient-button" id="search-submit" />
            </form>
        </article>
    </aside>
    <!--//sidebar-->

Related posts

Leave a Reply

1 comment

  1. From what I see when I look at the page under accommodations is hotel and villa. Those two seem to work fine. From what I see I cannot quite determine what your problem is. Could you reword it a little bit please?