WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called price that has a numeric value between 100 and 1000.

Here's the catch:

I'd like to integrate this with the Multiple Category Selection plugin (http://wordpress.org/extend/plugins/multiple-category-selection-widget/)

Here's the code that the Multiple Category Selection plugin is creating for me:

<form action="" method="post" class="wpmcsw">
<input type="hidden" name="ajax_url" value="http://rentscholar.com/wp-admin/admin-ajax.php" id="ajax_url" />
      <input type="hidden" name="ex_cats" value="" id="ex_cats" />
      <input type="hidden" name="default" value="" id="default" />
      <input type="hidden" name="blank" value="all" id="blank" />
      <input type="hidden" name="order" value="default" id="order" />
      <input type="hidden" name="mcsw" value="1" id="mcsw" />    
      <div class="select_wrapper">
    <select name="wpmm[]" >
    <option value="0">Parent Category</option><option  value="8">Child Category One</option><option  value="9">Child Category Two</option></select></div><input type="hidden" name="mmctype" value="in" />
        <input type="submit" value="Search" /></form>
share|improve this question
Hello Can u explain in brief – Arvind Pal Mar 21 '13 at 6:03
Need a search function that allows users to select a categories as well as enter a min and max price value. – Andrew Hendrie Mar 21 '13 at 12:36

May this code help

$args = array(
    'cat' => 'Category id'
    'post_type' => 'post type',
    'meta_key' => 'enter your metakey',
    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    'meta_query' => array(
           'key' => 'age',
           'value' => array(min price, max price),
           'compare' => 'IN',
$query = new WP_Query($args);

$query will contain an Array of post objects.



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.