2017-05-30 71 views
0

我在我的網站上使用WP作業管理器插件。在主頁上,我使用帶有位置搜索輸入的英雄搜索過濾器,這是目前的文本輸入,但我想通過設置選項將其更改爲下拉菜單。我可以使用所選選項輕鬆地將位置文本輸入更改爲下拉菜單。 我點擊搜索,下面的工作列表中沒有任何變化。WP工作經理位置下拉框

我試圖改變輸入在源文件中處理的方式,但沒有運氣。當我在作業列表頁面上輸出「位置」輸入的結果時,它仍然以空白字段的形式返回。

我不知道什麼els試圖完成所需的結果,所以任何幫助或輸入將不勝感激。

以下代碼是我的part-job-filters.php代碼。

<?php 
    if (! class_exists('WP_Job_Manager')) { 
     return; 
    } 

    $keywords   = ''; 
    $location   = array(); 
    $selected_category = array(); 

    if (! empty($_GET['search_keywords'])) { 
     $keywords = sanitize_text_field($_GET['search_keywords']); 
    } 
    // Old Location input field 
    // if (! empty($_GET['search_location'])) { 
    // $location = sanitize_text_field($_GET['search_location']); 
    // } 

    if (! empty($_GET['search_location'])) { 
     $location = absint($_GET['search_location']); 
    } 

    if (! empty($_GET['search_category'])) { 
     if (is_array($_GET['search_category'])) { 
      $selected_category = absint(reset($_GET['search_category'])); 
     } else { 
      $selected_category = absint($_GET['search_category']); 
     } 
     $_GET['search_category'] = $selected_category; 
    } 

    if (is_tax('job_listing_category')) { 
     $term = get_queried_object(); 
     $_GET['search_category'] = $selected_category = array($term->term_id); 
    } 

?> 


<div class="form-filter"> 
    <div class="form-filter-header"> 
     <a href="#" class="form-filter-dismiss">&times;<span class="sr-only"> <?php esc_html_e('Dismiss filters', 'specialty'); ?></span></a> 
    </div> 

    <?php 
     $has_categories = true; 
     $count = wp_count_terms('job_listing_category', array(
      'hide_empty' => 1, // Hide empty, as they are not displayed by the dropdown anyway. 
     )); 
     if (is_wp_error($count) || 0 === intval($count) || is_tax('job_listing_category')) { 
      $has_categories = false; 
     } 

     $col_classes = array(
      'keywords' => 'col-lg-3 col-xs-12', 
      'location' => 'col-lg-3 col-xs-12', 
      'category' => 'col-lg-3 col-xs-12', 
      'button'  => 'col-lg-3 col-xs-12', 
     ); 

     if (! get_option('job_manager_enable_categories') || ! $has_categories) { 
      $col_classes = array(
       'keywords' => 'col-lg-4 col-xs-12', 
       'location' => 'col-lg-4 col-xs-12', 
       'category' => '', 
       'button'  => 'col-lg-3 push-lg-1 col-xs-12', 
      ); 
     } 
    ?> 
    <div class="container"> 
     <div class="row"> 
      <div class="<?php echo esc_attr($col_classes['keywords']); ?>"> 
       <label for="job-keywords" class="sr-only"><?php esc_html_e('Job Keywords', 'specialty'); ?></label> 
       <input type="text" id="job-keywords" name="search_keywords" placeholder="<?php esc_attr_e('Keywords', 'specialty'); ?>" value="<?php echo esc_attr($keywords); ?>"> 
      </div> 

      <div class="<?php echo esc_attr($col_classes['location']); ?>"> 
       <label for="job-location" class="sr-only"><?php esc_html_e('Job Location', 'specialty'); ?></label> 
       <div class="ci-select"> 

        <select name="search_location" id="job-location" data-no_results_text="No results match" data-multiple_text="Select Some Options"> 
          <option value="0">Select a location</option> 
          <option value="Eastern Cape">Eastern Cape</option> 
          <option value="Free State">Free State</option> 
          <option value="Gauteng">Gauteng</option> 
          <option value="kwazulu natal">kwazulu natal</option> 
          <option value="Limpopo">Limpopo</option> 
          <option value="Mpumalanga">Mpumalanga</option> 
          <option value="North West">North West</option> 
          <option value="Northern Cape">Northern Cape</option> 
          <option value="Western Cape">Western Cape</option> 
          <option value="Africa">Africa</option> 
          <option value="International">International</option> 
          <option value="All locations">All locations</option> 
        </select> 

       </div> 
      </div> 


      <?php if (get_option('job_manager_enable_categories') && $has_categories) : ?> 
       <div class="<?php echo esc_attr($col_classes['category']); ?>"> 
        <label for="job-category" class="sr-only"><?php esc_html_e('Job Category', 'specialty'); ?></label> 
        <div class="ci-select"> 
         <?php 
          $multiple = get_option('job_manager_enable_default_category_multiselect'); 

          job_manager_dropdown_categories(array(
           'taxonomy'  => 'job_listing_category', 
           'hierarchical' => 1, 
           'show_option_all' => $multiple ? false : esc_html__('Any category', 'specialty'), 
           'name'   => 'search_category', 
           'orderby'   => 'name', 
           'selected'  => $selected_category, 
           'multiple'  => $multiple, 
          )); 
         ?> 
        </div> 
       </div> 
      <?php endif; ?> 

      <div class="<?php echo esc_attr($col_classes['button']); ?>"> 
       <button class="btn btn-block btn-jobs-filter" type="submit"><?php esc_html_e('Search', 'specialty'); ?></button> 
      </div> 
     </div> 
    </div> 
</div> 

我可能正在接近這個錯誤的方式,如果有的話,請有人建議什麼是正確的方式接近這一點。

回答

0

將select元素中的id替換爲id =「job-location」爲id =「search_location」。