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
-
June 11, 2020 at 4:15 pm #27805
Alex Meda
ParticipantYou cannot access this content.
June 11, 2020 at 4:25 pm #27807Alex Meda
ParticipantYou cannot access this content.
June 11, 2020 at 4:58 pm #27808Alex Meda
ParticipantYou cannot access this content.
June 12, 2020 at 2:26 pm #27830Ernest Marcinko
KeymasterThanks. The custom code was almost working perfectly, I adjusted it a bit to give the same output as the advanced title field. I removed the address_field from the advanced title field, as it is no longer needed there.
The final code is:
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 = 'title'; // '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 != '' ) { $meta_value = '<p>Location: ' . $meta_value . '</p>'; 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 12, 2020 at 9:46 pm #27839Alex Meda
ParticipantYou cannot access this content.
June 15, 2020 at 9:39 am #27852Ernest Marcinko
KeymasterYou cannot access this content.
June 19, 2020 at 12:07 am #27953Alex Meda
ParticipantYou cannot access this content.
June 19, 2020 at 10:02 am #27962Ernest Marcinko
KeymasterHi,
The desktop one looks like some sort of CSS conflict there. Possibly a forced margin/padding of some sort. I will have to see that to tell exactly.
The mobile might be just this option: https://i.imgur.com/R682367.png
If it’s enabled, the results switch to a “hover” mode automatically.June 20, 2020 at 4:18 am #27976Alex Meda
ParticipantYou cannot access this content.
June 22, 2020 at 11:43 am #27998Ernest Marcinko
KeymasterYou cannot access this content.
June 22, 2020 at 8:20 pm #28030Alex Meda
ParticipantHappy Monday,
You’re right! I tried it on 3 other computers and it works perfectly so my laptop screen resolution was definitely the right issue(I will fix it).ON MOBILE PHONE
I tried it on a “iPhone Pro 11”, and the the pagination arrows which display more results seems to not working as it should be. As a matter of fact, when you click on the arrows for more results, all the results disappear all of a sudden. I am not sure yet if the issue was the phone resolution but I will make sure to test it on many other iPhone Devices to be sure.One last thing please, on mobile phones, I want the “Settings Box”(The filters bar) to be displayed only if the user starts typing something to be searched. How to make it work?
Thank you!
June 22, 2020 at 8:39 pm #28031Alex Meda
ParticipantI was almost forgetting about this one but I would like to invite logged out users to register when they click on one of the results.
So my question is to know if you could set up a custom redirection link to registration page for logged out users when they wish to see the whole content of the result which they clicked on it.
June 23, 2020 at 2:13 pm #28052Ernest Marcinko
KeymasterHi,
Well, I’m afraid the thing with the settings is not possible – that needs to be custom coded somehow. There is a javascript API, that may help, if you decide to try it, or if a developer may need it.
The other one with the logged in users is also a custom coding issue, but should be simpler. Based on this knowledge base, I would try something like this:
add_filter( 'asp_results', 'asp_custom_link_results', 10, 1 ); function asp_custom_link_results( $results ) { $link = 'https://www.google.com/'; // Link to use, when not logged in // Parse through each result item foreach ($results as $k=>$v) { if ( !is_user_logged_in() ) $results[$k]->link = $link; } return $results; }June 23, 2020 at 5:46 pm #28059Alex Meda
ParticipantYou cannot access this content.
June 24, 2020 at 8:21 am #28064Ernest Marcinko
KeymasterThe URL seems to be incorrect as the error message says. You added the URL starting with “https://”, while I guess it should be “http://”.
Everything required about the JS api should be in that documentation. You probably want to use the
ASP.api(0, "toggleSettings", "show");api method in a input type event on the search input. -
AuthorPosts
- You must be logged in to reply to this topic.