[wp-hackers] Bulding a full search form?

Alex King lists at alexking.org
Fri Oct 5 13:09:40 UTC 2012


I'd recommend setting "pet gender" as a custom taxonomy instead of as post meta. Performance would be much better querying by the taxonomy term than by meta value (non-indexed column).

Setting the default options as taxonomy terms can be done manually and to present a taxonomy as a set of fields in the post edit form, you can do a little jQuery hacking.

https://gist.github.com/3723819

Cheers,
--Alex

http://alexking.org | http://crowdfavorite.com




On Oct 4, 2012, at 6:54 PM, Diana K. C <dianakac at gmail.com> wrote:

> Hi there,
> 
> Í'm having some spare time to get to know about searching content in WP, I found some weak plugins, tips etc still anything helped at all.
> 
> In single meta_key I manage to search it this way:
> 
> Add this functions/plugin:
> 
>   global $wp;
>   $wp->add_query_var('meta_key');
>   $wp->add_query_var('meta_value');
>   $wp->add_query_var('meta_compare');
> 
> And form would be:
> 
> <form action="<?php echo home_url(); ?>/" method="get" id="searchform">
>     <input class="input" name="s" type="text" id="keywords" value="" >
> 
>           <select name="meta_value" id="img_post_country" >
>           <option value="" selected="selected">Select pet gender</option>
>           <option <?php if(isset($action_edit_image)){ ?> selected="selected" <?php } ?> value="<?php _e('Male','wp_pet');?>"><?php _e('Male','wp_pet');?></option>
>           <option value="<?php _e('Female','wp_pet');?>"><?php _e('Female','wp_pet');?></option>
>           </select>
> 
>    <input type="hidden" name="post_type" value="pet" />
> 
>            <input type="submit" name="search" value="<?php _e('Search','cosmotheme') ?>">
>    </form>
> 
> There's no way to search more than a meta_key with this, it would be nice if I could set the meta_key name in the input name instead of "meta_value", then I could use more than one meta_key. I tried but doesn't work :(
> 
> 
> I found this also http://wordpress.stackexchange.com/questions/38361/advanced-search-form-with-filters-for-custom-taxonomies-and-custom-fields
> 
> Beside the fact I'm lacking knowledge on post data e sessions, is this a sort of a hack?
> 
> Thanx!



More information about the wp-hackers mailing list