[wp-hackers] Bulding a full search form?

Diana K. C dianakac at gmail.com
Fri Oct 5 00:54:56 UTC 2012


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