Skip Navigation

[Resolved] Search view by localisation not working anymore

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 3 voices.

Last updated by Luo Yang 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2356461
address.PNG
query filter.PNG
content selection.PNG
view.PNG
code.PNG

Hello,

In a previous post we were trying to find a solution to sort a custom post type view search by localisation on our website. Each post having an address field.

We got this code snippet (code screenshot) from the forum, the view id is 3845, the one we are using for the search page (see view screenshot).

In the view we selected the custom post type we wanted to sort (screenshot content selection). And then we have no query filters (we had one but it didn't work apparently and now it's impossible to create one, the button isn't working, see the query filter screenshot). And last part is the ordering, we tried different fields nothing worked, even the adresse practicien, which is the field we want to order by, wasn't working.

It's very strange because before everything worked, we were filtering severals custom post types with this view, everything was okay but then I removed the CPTs we used by another one, and only one (the praticien), and nothing is working anymore.

If you have any clue it would be fantastic, thank you in advance !

#2356849

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

"Nothing is working anymore".

Are there any errors in the browser console (JavaScript errors)?

If you are having problems using the editor, I'd expect there to be errors in the console that may give some clues as to the problem.

If there are errors, do you see the same errors if you try to recreate the page with the same blocks?

#2356873

Hello,

Which custom codes are you using? Is it this one:
https://toolset.com/forums/topic/sorting-views-by-distance-to-current-post-geolocation/#post-1140488
Since it is a custom codes issue, please provide a test site with same problem, fill below private message box with login details, also point out the problem page URLs, where I can edit your custom PHP codes.

I need to test and debug it in a live website, thanks

#2358733

I can login into your website, where can I see the problem you mentioned above?
Please point out:
- the problem page URL and view URLs,
- Where I can edit your custom PHP codes

#2358759

Heya,

here is the url of the page (and the view, as it is an embbed view): hidden link .

About the php code, it is in toolset > settings > custom codes > orderresults

If you need any other information let me know !

#2358853
orderby-distance2.JPG

You are using Blocks editor to design the page and view block, but feature "sort by distance" isn't available in view block yet, you need to use legacy editor to setup the post view:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/
Then you will be able to order the result by distance, see my screenshot: orderby-distance2.JPG

#2358895

Alright, thank you very much Luo. It was working before with the block editor and the php code but anyway, it's strange.

Then my question is how can I keep the design I built in the block editor to put it in a legacy view editor without doing it again ?

#2359521

You can use content template in views loop with content template, and use blocks editor to design the content template.

#2359805
auto fill google.PNG

So basically we created a legacy view and we have configured it, everything's working now but we got a last problem, we use 2 criterias for the searching. The keywords (linked to the title and description), and an address field. Both search fields are still working but we lost the google location pop up as we aren't using the view block editor anymore and we are using a raw html searchbar. If there any solution to make it appear ? (the pop us is the thing showed in auto fill google png).

Here is the raw html code we are using (xxxxx is the webiste, the view id is 9566):

<form autocomplete="off" action="hidden link" method="get" class="wpv-filter-form js-wpv-filter-form js-wpv-filter-form-9566 js-wpv-form-only js-wpv-dps-enabled" data-viewnumber="9566" data-targetid="9568" data-viewid="9566" data-viewhash="eyJuYW1lIjoiUlx1MDBlOXN1bHRhdHMgcmVjaGVyY2hlIiwidGFyZ2V0X2lkIjoiMzU5MSJ9" data-viewwidgetid="0" data-orderby="" data-order="" data-orderbyas="" data-orderbysecond="" data-ordersecond="" data-parametric="{" query":"normal","id":"9566","view_id":"9566","widget_id":0,"view_hash":"9566","action":"https:="" obesite-france.com="" resultats","sort":{"orderby":"","order":"","orderby_as":"","orderby_second":"","order_second":""},"orderby":"","order":"","orderby_as":"","orderby_second":"","order_second":"","ajax_form":"","ajax_results":"","effect":"fade","prebefore":"","before":"","after":"","attributes":[],"environment":{"current_post_id":174,"parent_post_id":0,"parent_term_id":0,"parent_user_id":0,"archive":{"type":"","name":"","data":[]}},"loop":{"type":"","name":"","data":[],"id":0}}"="" data-attributes="[]" data-environment="{" current_post_id":174,"parent_post_id":0,"parent_term_id":0,"parent_user_id":0,"archive":{"type":"","name":"","data":[]}}"="">
<div class="searchbar">
<div class="searchbar-query">
<div>
<div class="searchbar-input-wrapper">
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16" class="searchbar-input-icon">
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.312 13.322a.3.3 0 0 1 0 .425l-.564.565a.3.3 0 0 1-.425 0l-3.036-3.035a.307.307 0 0 1-.087-.212v-.33A5.2 5.2 0 0 1 1.6 6.8a5.2 5.2 0 0 1 5.2-5.2 5.2 5.2 0 0 1 3.935 8.6h.33c.08 0 .155.03.212.087l3.035 3.035zM6.8 10.8c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4z"></path>
</svg>
<input class="searchbar-input searchbar-query-input" placeholder="Service, mot clé, spécialité,..." aria-expanded="false" aria-activedescendant="false" aria-owns="search-query-input-results-container" aria-controls="search-query-input-results-container" aria-autocomplete="list" autocomplete="off" autocorrect="off" name="wpv_post_search" autocapitalize="off" spellcheck="false" id="autocomplete-default" role="combobox" value="">
</div>
</div>
</div>
<div class="searchbar-place-submit">
<div class="searchbar-place">
<div class="searchbar-place-input-wrapper">
<div class="searchbar-input-wrapper searchbar-input-hide-overflowing-around-me">
<svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16" class="searchbar-input-icon">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.6a4.8 4.8 0 0 0-4.797 4.62L3.2 6.4c0 1.778.6 2.334 3.782 7.436a1.2 1.2 0 0 0 2.036 0l.952-1.516c2.307-3.648 2.81-4.31 2.83-5.824V6.4A4.8 4.8 0 0 0 8 1.6zm0 11.6L5.568 9.34C4.575 7.737 4.4 7.289 4.4 6.4a3.6 3.6 0 0 1 7.196-.17l.004.17c0 1.364-.38 1.636-3.6 6.8zM6 6.4a2 2 0 1 1 4 0 2 2 0 0 1-4 0z"></path>
</svg>
<input class="form-control js-toolset-maps-distance-center js-wpv-filter-trigger-delayed js-toolset-maps-address-autocomplete pac-target-input searchbar-input searchbar-place-input" placeholder="Où ?" aria-expanded="false" aria-activedescendant="false" aria-owns="search-place-input-results-container" aria-controls="search-place-input-results-container" aria-autocomplete="list" autocomplete="off" autocorrect="off" id="toolset-maps-distance-center" name="toolset_maps_distance_center" autocapitalize="off" spellcheck="false" role="combobox" value="">
</div>
</div>
</div>
<input id="toolset-maps_distance_value" name="toolset_maps_distance_radius" style="display:None;" value="">
<select id="toolset-maps-distance" name="toolset_maps_distance_unit" style="display:None;">
<option selected="" value="km">km</option>
</select>
<button class="Tappable-inactive dl-button-DEPRECATED_yellow searchbar-submit-button dl-button dl-button-size-normal" role="button" type="submit" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); user-select: none; cursor: pointer;">
<span class="dl-button-label">
<span class="searchbar-submit-button-label dl-text-transform-none">Rechercher</span>
<svg class="searchbar-submit-button-arrow" width="10" height="16" viewBox="0 0 10 16">
<path d="M2.7.5c-.2-.3-.5-.5-1-.5S1 .2.5.5C-.2 1-.2 2 .5 2.7L5.7 8 .5 13.5c-.7.8-.7 1.5 0 2.2.3.3.7.4 1.2.4.4 0 .8 0 1-.3L9 9c.3-.2.4-.5.4-1 0-.4 0-.8-.4-1L2.7.5z"></path>
</svg>
</span>
</button>
</div>
</div>
</form>

#2360277

Please try map shortcode , for example:

[wpv-geolocation message_when_missing="We need your location to show this content"]
[/wpv-geolocation]

Clear your browser cache and test again.

More help:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-geolocation
... it will ask the visitor for location, save it so that it is available to the backend and then reload the page ...