[Resolved] Search using Select Option drop box populated by Custom Field
I am running the following code to generate a drop-down box, used to search by a custom field called “area”.
<form method="get" action="<?php bloginfo('home'); ?>/"> <select value="<?php the_search_query(); ?>" name="s" id="s" tabindex="1" size="1"> <option value="">Select an Area</option> <?php query_posts('cat=3,4,5,6,7,8,9&showposts=50&orderby=author'); ?> <?php while (have_posts()) : the_post(); ?> <option value="<?php echo get_post_meta($post->ID, 'area', true); ?>"><?php echo get_post_meta($post->ID, 'area', true); ?></option> <?php endwhile; ?> <?php wp_reset_query(); ?> </select> <input type="hidden" name="key" value="area" /> <input type="submit" id="searchsubmit" value="Go" /> </form>
The problem i am having (as you’d expect!) is that this returns all the values in that field, so that I have multiple entries of each search term.
ie: if i have 3 posts with “area” set to “Banana”, i will get 3 “Banana”‘s in my search drop box.
I’m afriad this is a bit beyond my expertise.. Can anyone help me out with a way to fix this issue?
- The topic ‘[Resolved] Search using Select Option drop box populated by Custom Field’ is closed to new replies.