WordPress.org

Ready to get started?Download WordPress

Forums

Filter search results based on meta (2 posts)

  1. robmuzo
    Member
    Posted 3 years ago #

    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.

  2. robmuzo
    Member
    Posted 3 years ago #

    this plugin solves the issue:

    Taxonomy Picker
    http://wordpress.org/extend/plugins/taxonomy-picker/

Topic Closed

This topic has been closed to new replies.

About this Topic