Add search bar in bannel HTML

Closed
Panagea - Hotel and Tours Booking WordPress Theme Panagea - Hotel and Tours Booking WordPress Theme March 16, 2019
Login to reply
harry smith
4 years ago
Resolved.
harry smith
4 years ago

Got it

Kelly R Support Agent
4 years ago

Hi,

Please find following code in /wp-content/panagea-booking/inc/shortcodes/templates/searchform.php file.

function panagea_shortcode_searchform( $atts, $content = null ) {

extract( shortcode_atts( array( 
   'post_type' => 'all',
   'extra_class' => '',
   'animation' => '',
   'animation_delay' => 1
  ), $atts ) );

 $animation_classes = panagea_getCSSAnimation( $animation );
 $post_types = array( 'all', 'tour', 'hotel', 'restaurant' );
 if ( ! in_array( $post_type, $post_types ) ) {
  $post_type = 'all';
 }

 $modules = panagea_get_available_modules();
 if ( empty( $modules ) || ( $post_type != 'all' && ! in_array( $post_type, $modules ) ) ) {
  return '';
 }

 ob_start();
 ?>
 <form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" >
  <?php if ( $post_type != 'all' ) : ?>
   <input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>">
  <?php endif; ?>

  <div class="row no-gutters custom-search-input-2 <?php echo esc_attr( $extra_class ) . ' ' . esc_attr( $animation_classes ); ?>" style="animation-delay: <?php echo esc_attr( $animation_delay ); ?>s;">
   <div class="col-lg-4">
    <div class="form-group">
     <input name="s" class="form-control" type="text" placeholder="<?php esc_attr_e( 'What are you looking for...', 'panagea-booking' ); ?>">
     <i class="icon_search"></i>
    </div>
   </div>
   <div class="col-lg-3">
    <div class="form-group">
     <?php
      $all_districts = get_terms( 'district', array( 'hide_empty' => 0 ) );
      if ( ! empty( $all_districts ) ) : ?>
      <select class="wide" name="districts[]">
       <option value="" selected><?php _e( 'All Districts', 'panagea-booking' ); ?></option>
       <?php
       foreach ( $all_districts as $each_district ) {
        $term_id = $each_district->term_id;
        ?>
        <option value="<?php echo esc_attr( $term_id ); ?>"><?php echo esc_html( $each_district->name ); ?></option>
        <?php
       }
       ?>
      </select>
     <?php endif; ?>
    </div>
   </div>
   <div class="col-lg-3">
    <?php
    switch ( $post_type ) {
     case 'all':
      $module_title = array(
        'tour' => __( 'Tours', 'panagea-booking' ),
        'hotel' => __( 'Hotels', 'panagea-booking' ),
        'restaurant' => __( 'Restaurants', 'panagea-booking' ),
       )
      ?>
      <select class="wide" name="post_type">
       <?php foreach ( $modules as $module ) : ?>
        <option value="<?php echo esc_attr( $module ); ?>"><?php echo esc_html( $module_title[$module] ); ?></option>
       <?php endforeach; ?>
      </select>
      <?php
      break;

     case 'tour':
      $all_tour_types = get_terms( 'tour_type', array( 'hide_empty' => 0 ) );
      if ( ! empty( $all_tour_types ) ) {
       ?>
       <select class="wide" name="tour_types[]">
        <option value="" selected><?php _e( 'All Categories', 'panagea-booking' ); ?></option>
        <?php
        foreach ( $all_tour_types as $each_tour_type ) {
         $term_id = $each_tour_type->term_id;
         ?>
         <option value="<?php echo esc_attr( $term_id ); ?>" ><?php echo esc_html( $each_tour_type->name ); ?></option>
         <?php
        }
        ?>
       </select>
       <?php
      }
      break;

     case 'hotel':
      $all_hotel_types = get_terms( 'hotel_type', array( 'hide_empty' => 0 ) );
      if ( ! empty( $all_hotel_types ) ) {
       ?>
       <select class="wide" name="hotel_types[]">
        <option value="" selected><?php _e( 'All Categories', 'panagea-booking' ); ?></option>
        <?php
        foreach ( $all_hotel_types as $each_hotel_type ) {
         $term_id = $each_hotel_type->term_id;
         ?>
         <option value="<?php echo esc_attr( $term_id ); ?>" ><?php echo esc_html( $each_hotel_type->name ); ?></option>
         <?php
        }
        ?>
       </select>
       <?php
      }
      break;

     case 'restaurant':
      $all_restaurant_types = get_terms( 'restaurant_type', array( 'hide_empty' => 0 ) );
      if ( ! empty( $all_restaurant_types ) ) {
       ?>
       <select class="wide" name="restaurant_types[]">
        <option value="" selected><?php _e( 'All Categories', 'panagea-booking' ); ?></option>
        <?php
        foreach ( $all_restaurant_types as $each_restaurant_type ) {
         $term_id = $each_restaurant_type->term_id;
         ?>
         <option value="<?php echo esc_attr( $term_id ); ?>" ><?php echo esc_html( $each_restaurant_type->name ); ?></option>
         <?php
        }
        ?>
       </select>
       <?php
      }
      break;
    }
    ?>
   </div>
   <div class="col-lg-2">
    <input type="submit" class="btn_search" value="<?php esc_attr_e( 'Search', 'panagea-booking' ); ?>">
   </div>
  </div>
  <!-- /row -->
 </form>

 <?php
 $html = ob_get_clean();
 return $html;
}

And replace with following.

function panagea_shortcode_searchform( $atts, $content = null ) {

extract( shortcode_atts( array( 
   'post_type' => 'all',
   'extra_class' => '',
   'animation' => '',
   'animation_delay' => 1
  ), $atts ) );

 $animation_classes = panagea_getCSSAnimation( $animation );
 $post_types = array( 'all', 'tour', 'hotel', 'restaurant' );
 if ( ! in_array( $post_type, $post_types ) ) {
  $post_type = 'all';
 }

 $modules = panagea_get_available_modules();
 if ( empty( $modules ) || ( $post_type != 'all' && ! in_array( $post_type, $modules ) ) ) {
  return '';
 }

 ob_start();
 ?>
 <form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" >
  <?php if ( $post_type != 'all' ) : ?>
   <input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>">
  <?php endif; ?>

  <div class="row no-gutters custom-search-input-2 <?php echo esc_attr( $extra_class ) . ' ' . esc_attr( $animation_classes ); ?>" style="animation-delay: <?php echo esc_attr( $animation_delay ); ?>s;">
   <div class="col-lg-10">
    <div class="form-group">
     <input name="s" class="form-control" type="text" placeholder="<?php esc_attr_e( 'What are you looking for...', 'panagea-booking' ); ?>">
     <i class="icon_search"></i>
    </div>
   </div>
   <div class="col-lg-2">
    <input type="submit" class="btn_search" value="<?php esc_attr_e( 'Search', 'panagea-booking' ); ?>">
   </div>
  </div>
  <!-- /row -->
 </form>

 <?php
 $html = ob_get_clean();
 return $html;
}

Regards, C-Themes

harry smith
4 years ago

I want to hide selection: District and Hotel 

And I want the search box use their space also, like the pic Capture2.png

Kelly R Support Agent
4 years ago

HI,

Panagea WordPress theme has not such feature.

Please check our demo site in https://panagea.c-themes.com/

Regards, C-Themes

harry smith
4 years ago

How can I add a search bar can search all modules as same as the homepage of HTML 5 version?