Wordpress search custom fields -


i have custom field meta_name product_id. trying determine how search field when using wordpress search.

i know wordpress search results page uses query_string contains "s" value keyword searched don't know how change code below search custom field mentioned.

$loop = new wp_query("$query_string . '&posts_per_page=-1&post_type=product'"); ?>  

think section in codex should have answers need regards adding in custom field parameters query:

http://codex.wordpress.org/function_reference/wp_query#custom_field_parameters

not sure whether allow search within particular custom field though. can't think you'd have make changes on search form end of things. see how on adding in custom field parameters.

off top of head think need like:

$query = new wp_query( array(      'meta_key' => 'product_id',      'meta_value' => $query_string,     'posts_per_page' => '-1',     'post_type' => 'product'  ) ); 

not tested though!


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -