[wp-hackers] Bulding a full search form?

Joshua Sibelman joshua.sibelman at gmail.com
Sat Oct 6 19:32:20 UTC 2012


It doesn't matter if the taxonomy only has two possible values. Database queries will still be faster against the indexed columns of the taxonomy tables vs. the non-indexed postmeta values.



On Oct 6, 2012, at 11:45 AM, "Diana K. C" <dianakac at gmail.com> wrote:

> Because some taxonomies will store only 2 itens such gender?!
> 
> Ok to auto populate and filter but thought metadata would be faster, now I'm confused :S
> 
> ----- Original Message ----- From: "Alex King" <lists at alexking.org>
> To: <wp-hackers at lists.automattic.com>
> Sent: Saturday, October 06, 2012 10:22 AM
> Subject: Re: [wp-hackers] Bulding a full search form?
> 
> 
> Why would it be bad to create custom taxonomies?
> 
> On Friday, October 5, 2012, Diana K. C wrote:
> 
>> 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 <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<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<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>> ______________________________**_________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers 
> _______________________________________________
> 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