• Hi I am trying to filter a search based on it having 2 sets of meta

    So the search would be:

    1.Keyword
    2.Meta Value 1
    3.Meta Value 2

    The end user would put in keyword and then select the meta values from a drop down box queried from the database which I already have worked out how to do:

    <form name="search" action="" method="get">
      <select name="option">
      <?php
      $metakey = 'option';
      $options = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
      if ($options) {
        foreach ($options as $option) {
          echo "<option value=\"" . $option . "\">" . $option . "</option>";
        }
      }
      ?>

    And then submit and the search would be filtered by keyword and if it had meta from Meta Value 1 and 2.

    Any ideas on how I might get this to work?

    Thanks.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Filter search results based on meta’ is closed to new replies.