Adding custom filter

Closed
CityTours - Hotel & Tour Booking WordPress Theme CityTours - Hotel & Tour Booking WordPress Theme November 29, 2018
Login to reply
Kelly R Support Agent
5 years ago
Resolved.
Kelly R Support Agent
5 years ago

Hi,

As I said in last message, search engine is complex because it only shows available hotels. It means if hotel has not available rooms, it will be not shown in search result. So it is very difficult to add another filter in search page.

Regards, C-Themes

michael may
5 years ago

Hi Kelly,


Okay I edited the file like so : 


  <?php 

                    endif;


                    if ( ! empty( $ct_options['hotel_district_filter'] ) ) :

                        ?>


                        <div class="filter_type">

                            <h6><?php echo esc_html__( 'Regio', 'citytours' ) ?></h6>


                            <ul class="list-filter district-filter" data-base-url="<?php echo esc_url( remove_query_arg( array( 'districts', 'page' ) ) ); ?>" data-arg="districts">


                                <?php

                                $all_districts = get_terms( 'district', array('hide_empty' => 0) );


                                if ( ! empty( $all_districts ) ) :

                                    foreach ( $all_districts as $district ) {

                                        $term_id = $district->term_id;

                                        $checked = ( in_array( $term_id, $districts ) ) ? ' checked="checked"' : '';


                                        echo '<li><label><input type="checkbox" name="district_filter[]" value="' . esc_attr( $term_id ) . '"' . $checked . '>' . esc_html( $district->name ) . '</label></li>';

                                    }

                                endif;

                                ?>


                            </ul>

                        </div>


                   


                        <div class="filter_type">

                            <h6><?php echo esc_html__( 'Soort', 'citytours' ) ?></h6>


                            <ul class="list-filter district-filter" data-base-url="<?php echo esc_url( remove_query_arg( array( 'soorten', 'page' ) ) ); ?>" data-arg="soorten">


                                <?php

                                $alle_soorten = get_terms( 'soort', array('hide_empty' => 0) );


                                if ( ! empty( $alle_soorten ) ) :

                                    foreach ( $alle_soorten as $soort_filter ) {

                                        $term_id = $soort_filter->term_id;

                                        $checked = ( in_array( $term_id, $soort_filter ) ) ? ' checked="checked"' : '';


                                        echo '<li><label><input type="checkbox" name="soorten[]" value="' . esc_attr( $term_id ) . '"' . $checked . '>' . esc_html( $soort_filter->name ) . '</label></li>';

                                    }

                                endif;

                                ?>


                            </ul>

                        </div>


                        <?php 

                    endif;


                    ?>



and also added the same logic as districts in the functions in /inc/frontend/hotel/functions.php .

But where does this name argument pull data from? :   name="district_filter[]"  That is in the districts filter in: 


  echo '<li><label><input type="checkbox" name="district_filter[]" value="' . esc_attr( $term_id ) . '"' . $checked . '>' . esc_html( $district->name ) . '</label></li>';


Could you advise?

thx


Kelly R Support Agent
5 years ago

Hi,

You can make new taxonomy in /ct-bookings.php file in ct-booking plugin folder.

We made district taxonomy in this file.

And it is difficult to add another filter in hotel search.

You can edit /archive-hotel.php file and ct_hotel_get_search_result functio in /inc/frontend/hotel/functions.php file in CityTours theme folder.

$ct_options['hotel_district_filter'] is from theme options panel and you don't use for another taxonomy filter.

Regards, C-Themes


michael may
5 years ago

Hi,


Ive made a new taxonomy for the CPT 'hotel'


However i want the user to be able to filter hotels with the custom filter in the front end of the /?post_type=hotel page.

I know its this code below, but i was wondering where the taxonomies are registered? I can't find where the $ct_options['hotel_district_filter] . is registered?


So that i can copy it and replace my own taxonomy. 

Please advise!


thx Michael


--

the code --> from Archives.hotel


if ( ! empty( $ct_options['hotel_district_filter'] ) ) :

                        ?>


                        <div class="filter_type">

                            <h6><?php echo esc_html__( 'Regio', 'citytours' ) ?></h6>


                            <ul class="list-filter district-filter" data-base-url="<?php echo esc_url( remove_query_arg( array( 'districts', 'page' ) ) ); ?>" data-arg="districts">


                                <?php

                                $all_districts = get_terms( 'district', array('hide_empty' => 0) );


                                if ( ! empty( $all_districts ) ) :

                                    foreach ( $all_districts as $district ) {

                                        $term_id = $district->term_id;

                                        $checked = ( in_array( $term_id, $districts ) ) ? ' checked="checked"' : '';


                                        echo '<li><label><input type="checkbox" name="district_filter[]" value="' . esc_attr( $term_id ) . '"' . $checked . '>' . esc_html( $district->name ) . '</label></li>';

                                    }

                                endif;

                                ?>


                            </ul>

                        </div>


                        <?php 

                    endif;