Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Not all results showing when searching custom field value
This topic contains 12 replies, has 2 voices, and was last updated by mattand2707 3 years, 7 months ago.
- AuthorPosts
- October 23, 2019 at 9:14 am #24407
Hi Ernest,
On a real estate site I am developing I use drop downs based on custom fields. Im using {get_values}. Mostly it works well but on one search item, ‘property type’ the values are letters, a for appartment, m for house, etc. When i search in the drop down for c for commercial, only one result shows up, although there are at least 6 records/posts corresponding to ‘c’. If I use a custom query to search, all the 6 records(posts) show up in the results. Here is part of the php query:
$querystr = ”
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = ‘property_type’
AND $wpdb->postmeta.meta_value = ‘C’
AND $wpdb->posts.post_status = ‘publish’
AND $wpdb->posts.post_type = ‘post’
AND $wpdb->posts.post_date < NOW()
ORDER BY RAND()
LIMIT 20
“;
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
This works perfectly (I use PHP code snippets in the page to get the result)But when I search ‘c’ in the drop down using Ajax search pro I just get one result. Like here:
http://3dimmopro.ch/2017/searcher/Search property type is the only filter (all others set to ‘any’). There are 6 posts with ‘c’ as the property type but only one shows up in the results. I’m not using ACF and I know the records are there because I’m using a custom query in another area of the site.
How can I get ALL the 6 results to show up in a search? Is there something I’m missing? I’ve been right through the documentation and searched on google but can’t find the solution.
I hope I have explained myself clearly!
Otherwise excellent plugin and just what my client requires.
Many thanks
Matt
October 23, 2019 at 12:24 pm #24412Hi Matt,
I think I know why. By default, the minimum word length is set to 2, which means, that single character queries are executed a bit differently. Please try changing this option to either 0 or 1: https://i.imgur.com/o3VMBFK.png
Best,
That should very likely do the trick.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 23, 2019 at 12:34 pm #24413Hi ernest,
Thanks again for your quick reply!
When I change it to 0 or 1 it brings up 200 results!
It should only bring up 6
Anythihg else I should change?
cheers
mattOctober 23, 2019 at 12:39 pm #24414Hi Matt,
Can you please add temporary FTP and back-end details? I would like to check the exact configuration, and how the query is executed there. Thank you!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 23, 2019 at 12:53 pm #24415You cannot access this content.October 23, 2019 at 12:54 pm #24416Demo search page is here:
http://3dimmopro.ch/2017/searcher/October 23, 2019 at 2:53 pm #24420Thank you!
I have found the issue. It is the no_of_rooms (Pieces) filter. On the missing results this is set to 0, while the fitler range is 1-30. If you change the range to 0-30, or change the value of that field, then it should be fixed.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 23, 2019 at 3:35 pm #24423Hi Ernest,
Thanks for looking at this so quickly.
I have changed the ‘number of rooms’ range to 0-30 but it still brings up 200 results.
The search page is http://3dimmopro.ch/2017/searcher/ and the ‘property type’ dropdown is at the bottom of the search box.
Any other ideas?
Many thanks
MattOctober 23, 2019 at 3:38 pm #24424Hi Matt,
Have you added the “Commercial” option with the value “C” to the filter? I don’t see it there yet: https://i.imgur.com/iBttfJg.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 23, 2019 at 3:48 pm #24425Hi Ernest,
Yes, I’m using {get_values}
It’s here http://3dimmopro.ch/2017/searcher/
on the bottom row: ‘Property Type’
cheers
MattOctober 23, 2019 at 3:51 pm #24426The page is hidden, ie Its not on the front page of the site, I want to hardcode the search results as links in the top menu so I’m just using it to get the URLs. That way I can make a menu item ‘Commercial’
October 23, 2019 at 3:52 pm #24427Oh, so you had two filters for the property_type, that is what confused me. The issue was, that the filter type was set to “equals” which is a numeric operator, while it should have been “exactly like”: https://i.imgur.com/zeRJZI1.png
Best,
I changed it, and now it seems to be okay. I would not recommend however using two different drop-down filters for the same field (Property Type and the Type de Bien)
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 23, 2019 at 4:03 pm #24428Wow thanks Ernest! That seems to have done it! Brilliant!
No, usually I wouldn’t use two different drop-downs for the same field, this is just my test page.
Many thanks for all your help
Matt - AuthorPosts
You must be logged in to reply to this topic.