[wp-hackers] Bulding a full search form?

Diana K. C dianakac at gmail.com
Fri Oct 5 18:52:38 UTC 2012


Thanks Alex, I'm concerned about performance indeed.

I thought that itens such gender only can have 2 values ever, so this data 
should be stored as post meta? Is not bad to create various taxonomies 
then?!


----- Original Message ----- 
From: "Alex King" <lists at alexking.org>
To: <wp-hackers at lists.automattic.com>
Sent: Friday, October 05, 2012 10:09 AM
Subject: Re: [wp-hackers] Bulding a full search form?


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!

_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers 



More information about the wp-hackers mailing list