Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Distance Filters
This topic contains 34 replies, has 2 voices, and was last updated by Alex Meda 4 years, 2 months ago.
- AuthorPosts
- May 16, 2020 at 8:39 pm #27404
Hi,
How to I add a “Distance Filter” to my website search filters bar using Ajax Search Pro?May 18, 2020 at 12:30 pm #27416Hi,
If you mean Geo location based distance filter, then that is not possible.
If you mean a numeric custom field based filter (a distance relative to a static number), then using a custom fields filter could work.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 21, 2020 at 5:19 am #27475I think that I didn’t explain it well. As a matter of fact I have already integrated a map where user can make a post and input a location(can be street name, city name or country). I indeed added this location field data as a filter in my search bar. The issue is that, when I am making a search activating the location filter , it shows me the exact location for sure but it includes the geo-coordinates, which I don’t want.
EXAMPLE
Location( user input): Montreal
Result in filters; 45.5017° N, 73.5673° W Montreal, CANADAPlease see the screenshot below. I want the filter to extract only the city name
Attachments:
You must be logged in to view attached files.May 21, 2020 at 1:14 pm #27488Hi,
Looking at the screenshot, unfortunately that is not part of this plugin – it is probably the theme integrated filters of some sort. I’m afraid this is not possible.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 25, 2020 at 8:44 pm #27537ok I understand but how do I set-up the following context;
I want all the search filters to be unchecked by default and when a user is playing around with the filters, I don’t want the search to trigger automatically.
The user must finish selecting the filters that he wanted and then clicks on search to start the research.Attachments:
You must be logged in to view attached files.May 26, 2020 at 9:15 am #27550Hi,
You can turn off the facet triggers under here: https://i.imgur.com/wD6EMaG.png
Best,
That will prevent the search from triggering, until the search button is clicked.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 26, 2020 at 8:01 pm #27571Hi,
It went totally amazing and by this way, it makes the research experience more comfortable for the user, thank you so much!Another search feature that I am looking forward to set up thanks to your expertise is going be according to the following context;
1.) Please, take a look at the following screenshot which displays the “The search-Results-List” of some custom posts.
2.) Each result shows the following information linked to the current post: “The tittle, the author and the date”Now my question is to know if by the same way it displays the information above, we can use the same technique to make it display some other custom fields information ?
Attachments:
You must be logged in to view attached files.May 27, 2020 at 12:16 pm #27582Hi,
Could be doable. First, you can turn on description fields for the isotopic results. Then, you probably have to change the description font color as well. Now the regular description should be visible below the title. Then the advanced content field allows you to display custom fields/taxonomy terms within the results.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
May 28, 2020 at 5:33 pm #27639You cannot access this content.May 29, 2020 at 8:48 am #27645Hi,
Those look like a serialized array fields, not texts unfortunately. This is only possible to print via custom code, and even then it can be problematic.
Based on this tutorial, I would recommend using the code below for starters.
Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
Best,add_filter( 'asp_results', 'asp_custom_field_to_results', 10, 1 ); function asp_custom_field_to_results( $results ) { $custom_fields = 'address_field'; // Enter the custom field names, comma separated $field = 'content'; // 'title' or 'content' $position = 'after'; // 'before' or 'after' $delimiter = ' '; // character between the field value and the field $fields = explode(',', $custom_fields); foreach ( $fields as $custom_field ) { $custom_field = trim($custom_field); foreach ($results as $k=>&$r) { if ($r->content_type != 'pagepost') continue; if ( function_exists('get_field') ) $meta_value = get_field( $r->id, $custom_field, true ); // ACF support else $meta_value = get_post_meta( $r->id, $custom_field, true ); $meta_value = maybe_unserialize($meta_value); if ( is_array($meta_value) ) { $meta_value = implode(', ', $meta_value); } // Modify the post title to add the meta value if ( $meta_value != '' ) { if ( $field == 'title' ) { if ( $position == 'before' ) $r->title = $meta_value . $delimiter . $r->title; else $r->title .= $delimiter . $meta_value; } else { if ( $position == 'before' ) $r->content = $meta_value . $delimiter . $r->content; else $r->content .= $delimiter . $meta_value; } } } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 4, 2020 at 6:02 pm #27708Hi,
I’m still working on it because it is not working yet.June 5, 2020 at 12:23 pm #27717Hi,
Can you provide temporary FTP and back-end access? I can try to debug the code to see what is returned there. Thanks!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 10, 2020 at 3:52 pm #27783I will send you a private email including the new account username and password.
June 10, 2020 at 4:00 pm #27785You cannot access this content.June 11, 2020 at 8:24 am #27788You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.