0

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>
2
  • Hello Can u explain in brief
    – Arvind Pal
    Mar 21, 2013 at 6:03
  • Need a search function that allows users to select a categories as well as enter a min and max price value. Mar 21, 2013 at 12:36

1 Answer 1

0

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(
        array(
           'key' => 'age',
           'value' => array(min price, max price),
           'compare' => 'IN',
       )
    )
);
$query = new WP_Query($args);

$query will contain an Array of post objects.

Reference:

https://codex.wordpress.org/Class_Reference/WP_Query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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