title: How does one build a custom filter for wordpress?
body: <p>So I have been trying to work out how to build a way to filter through a large number of wordpress posts using user input. I am not quite sure I understand how to get this to work. I'll explain what I know so far briefly and maybe someone can point me in the right direction.</p>
  
  <p>So I understand I can use the wp_query($args) function to query my database and pass it my desired filtering arguments in order to get my desired result. Now because it has to be done by the user, I figured I could add a html form and did so like this</p>
  
  <pre><code>&lt;form class="navbar-form navbar-right" method="get"&gt;
  &lt;div class="form-group"&gt;
  Price($) &lt;input type="number" name="priceone" min="0" max="99" value="0"&gt; to
  &lt;input type="number" name="pricetwo" min="0" max="300"&gt;
  &lt;input type="submit" value="Search"&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I then wrote the php code as follows to display my wordpress loop on my home page. I am using the form get method to store the variables as php variable which will be used as a variable in the wp_query loop if the user presses submit. However this doesn't work.</p>
  
  <pre><code>&lt;?php 
    $minprice = $_GET["priceone"];
    $minprice = $_GET["pricetwo"];
    $args = array(
      'post_type' =&gt; 'food',
      'posts_per_page' =&gt; -1,
      'meta_query'=&gt; array(
      'key' =&gt; 'price',
      'value' =&gt; array($minprice,$maxprice),
      'compare' =&gt; 'BETWEEN',
      'type' =&gt; 'NUMERIC'
   )
  );
  
  $thefood = new WP_Query( $args ); 
  ?&gt;
  
  &lt;?php if ( $thefood-&gt;have_posts() ) : while ( $thefood-&gt;have_posts() ) : $thefood-&gt;the_post(); ?&gt;
  
  &lt;div class="col-lg-2 col-md-3 col-sm-4 col-xs-4" style="padding-left: 0; padding-right: 0;"&gt;
  &lt;?php the_post_thumbnail(full, array('class' =&gt; 'img-responsive')); ?&gt;
  &lt;/div&gt;
  
  &lt;?php endwhile; wp_reset_query(); else: ?&gt;
  &lt;p&gt;&lt;?php _e('Sorry, no food matched your criteria.'); ?&gt;&lt;/p&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>The loop worked fine and displayed all posts before I added the new price variables into it. Now when I press submit, it just does nothing but adds the variables onto the end of the url saying ?pricemin=3 etc..</p>
  
  <p>I feel like I am not understanding something. Can someone please point me in the right direction. Thank you</p>