Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Distance Filters
- This topic has 34 replies, 2 voices, and was last updated 5 years, 11 months ago by
Alex Meda.
-
AuthorPosts
-
May 16, 2020 at 8:39 pm #27404
Alex Meda
ParticipantHi,
How to I add a “Distance Filter” to my website search filters bar using Ajax Search Pro?May 18, 2020 at 12:30 pm #27416Ernest Marcinko
KeymasterHi,
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.
May 21, 2020 at 5:19 am #27475Alex Meda
ParticipantI 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
May 21, 2020 at 1:14 pm #27488Ernest Marcinko
KeymasterHi,
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.
May 25, 2020 at 8:44 pm #27537Alex Meda
Participantok 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.May 26, 2020 at 9:15 am #27550Ernest Marcinko
KeymasterHi,
You can turn off the facet triggers under here: https://i.imgur.com/wD6EMaG.png
That will prevent the search from triggering, until the search button is clicked.May 26, 2020 at 8:01 pm #27571Alex Meda
ParticipantHi,
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 ?
May 27, 2020 at 12:16 pm #27582Ernest Marcinko
KeymasterHi,
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.
May 28, 2020 at 5:33 pm #27639Alex Meda
ParticipantYou cannot access this content.
May 29, 2020 at 8:48 am #27645Ernest Marcinko
KeymasterHi,
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!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; }June 4, 2020 at 6:02 pm #27708Alex Meda
ParticipantHi,
I’m still working on it because it is not working yet.June 5, 2020 at 12:23 pm #27717Ernest Marcinko
KeymasterHi,
Can you provide temporary FTP and back-end access? I can try to debug the code to see what is returned there. Thanks!
June 10, 2020 at 3:52 pm #27783Alex Meda
ParticipantI will send you a private email including the new account username and password.
June 10, 2020 at 4:00 pm #27785Alex Meda
ParticipantYou cannot access this content.
June 11, 2020 at 8:24 am #27788Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.