Wordpress修改GET方法参数

时间:2016-06-03 18:25:31

标签: php regex wordpress get woocommerce

我正在进行自定义过滤,以便在用户选择值并单击搜索按钮时将参数传递到页面网址。但是我无法获得正确的输出参数。

为了使过滤工作,我需要一种看起来像这样的格式:
shop/?filter_tyre-width=22

我目前看到的是这样的:
shop/?tyre_width=22

如何在filter_符号后面插入前缀?

<?php 
  $terms_width = get_terms("pa_tyre-width");
  $terms_height = get_terms("pa_aspect-ratio");

  $filter_width = isset( $_GET['tyre_width'] ) ? esc_attr( $_GET['tyre_width'] ) : '';
  $filter_height = isset( $_GET['aspect-ratio'] ) ? esc_attr( $_GET['aspect-ratio'] ) : '';

  $new_link = add_query_arg( 'filtering', '1', $form_action );
  echo $new_link;

  echo '<form method="get" action="' . $new_link . '" class="col-md-12 clearfix">';

  echo '
          <div class="col-md-3">
          <label for="">Width</label>
          <div class="input-group select-large">
            <select id="tyre_width" name="tyre_width">
              <option>Select Width</option>
  ';
  foreach ( $terms_width as $term_width ) {
  echo '
          <option value="' . $term_width->name . '"> ' . $term_width->name . '</option>
  ';
  }
  echo '</select></div></div>';

  echo '
          <div class="col-md-3">
          <label for="">Height</label>
          <div class="input-group select-large">
            <select id="aspect-ratio" name="aspect-ratio">
  ';
  foreach ( $terms_height as $term_height ) {
  echo '
          <option value="' . $term_height->name . '"> ' . $term_height->name . '</option>
  ';
  }
  echo '</select></div></div>';

  echo '
  <div class="col-md-3">
        <div class="input-group search-btn">
        <label for="submit">Start Search!</label>
        <input type="submit" placeholder="Go" value="Search">
  </div>
  </form>';

0 个答案:

没有答案
相关问题