![]() |
hi experts,
I'm messing with search.php to use custom fields in it.
If you go to this site http://elook.ie/ and see the top search box. I added a custom field "location" I need to perform the search based on 3 things.
1. keywords
2. category
3. location i.e custom field
Following is the code I'm using..
I need it done ASAP. THanks It should work. Thanks for so fast reply. I uploaded your solution to site. I want you to make a sample search with location 'Kentucky' and ads should return all ads with that location 'Kentucky' Works, isn't it? hmm, have a look at this URL http://elook.ie/?s=boys&sa=search&cat=0&meta_value=Kentucky s=boys meta_value=Kentucky it should only return kentucky ads .. ?? Ok. What exactly do you want it to show? Please use Google Translate so I can understand your words. I want to show the posts depending on the selection criteria i.e keyword,category,custom field [location] So, It should return only those ads depending on the custom field [location]. if keywords are empty, it should just return the results based on category and location. I hope you got my point now ? Try to use this plugin: http://wordpress.org/extend/plugins/wp-custom-fields-search/ oh no, I don't want to use the plugin :( there is no solution without plugin ? Well I guess you can, check out this tutorial: http://tobymackenzie.wordpress.com/2009/11/18/stearns-wordpress-custom-queries/ can u tell me why this is not working ? Are you sure your meta key name is cp_state? BTW please raise your prize. yes, it is sure cp_state. btw, I can go max. $10 if I got what I wanted. otherwise it is a waste :( It should work, what's the problem? go here http://elook.ie/?s=boys&sa=search&cat=0&meta_value=Co.%20Derry it should just return the 1 ad with location 'Co. Derry' isn't it ? Try to print the $_GET variable and tell me its output. refresh the page now and you will see output http://elook.ie/?s=boys&sa=search&cat=0&meta_value=Co.%20Derry That's really weird. Are you sure the meta key is cp_state and not something else? see attached. Solution - 1
It should work. |
Wordpress |
Type: | Code Example |
Category: | Coding |
Sub Category: | Code Example |
Uploaded by: | Admin |
Views: | 8 |