I have a custom field with meta_name is product_id. I am trying to determine how to search that field when using the wordpress search.
I know the wordpress search results page uses query_string which contains the “s” value for the keyword searched I just don’t know how to change my code below to search the custom field mentioned.
$loop = new WP_Query("$query_string . '&posts_per_page=-1&post_type=product'"); ?>
think this section in the codex should have the answers you need with regards to adding in custom field parameters to you query:
http://codex.wordpress.org/Function_Reference/WP_Query#Custom_Field_Parameters
Not sure whether that will allow you to search within a particular custom field though. Can’t be certain but I think you’d have to make some changes on the search form end of things. See how you get on with adding in the custom field parameters.
Off the top of my head I would think you would need something like:
Not tested though!