Skip Navigation

[Resolved] Distance filter problem on archive page

This thread is resolved. Here is a description of the problem and solution.

Problem: I cannot get a distance filter to work on a WordPress Archive.

Solution: The distance filter feature is not fully implemented in WordPress Archives. The best way to get around this is to create a View that behaves like your WordPress Archive, using Query Filters. Then insert the View in your WordPress Archive, outside the wpv-loop tags. Cut everything from inside the wpv-loop tags and paste it inside the View's wpv-loop tags. Remove all filters from the old WordPress Archive.

This support ticket is created 6 years, 7 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 replies, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#630491

Hi team,

i have issue with distance filter, i already have full filter running .
what i did was just add the distance filter .

i tested with 1km radius i get the same number of listing all time, pls advice.

i follwed this guide : https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/#filtering-markers-by-distance

#630492

wonder, do i need another separate search button just for distance ?

#630583

Hi, you do not need a separate submit button just for the distance filter. It should be integrated with all the other filters. Can you tell me more about how this is implemented?
- Is this custom search in a View or a WordPress Archive?
- Are you trying to filter based on the User's current location, or based on the distance from a specific point?
- Do you have a map implemented? If so, are there Markers shown for each location? Are they shown in the correct place?
- If you change other filters on the View, do the results change?
- Is this View visible somewhere on the site?

#630586

Hi Christian,

1. its under wordpress archieve page.
2. user current location - " use my location "
3. map with markers is active
4. link: hidden link [site is blocked for google pls dont publish url anywhere 🙂 ]

thanks.

#630598

Hi. is this line fixed ?
distance_center_url_param="toolset_maps_distance_center"
distance_radius_url_param="toolset_maps_distance_radius"
distance_unit_url_param="toolset_maps_distance_unit"

can i change it to my likings ?

eg:distance_center_url_param="mysite_maps_distance_center"

thanks

#630601
#630603

Yes, it's most likely the same issue here. The distance filter is not yet implemented in WordPress Archives. You could achieve something similar with a custom search View, placed inside the WordPress Archive Loop Output editor, outside the wpv-loop tags. Then remove everything inside the wpv-loop tags.

#630606

thanks.
ill try now and update here soon. cheers

#630616

hi christian could you guide me step by step pls. correct me too

1. create new view '> post type : i must select ? cant be auto detect ?

2. query filter : distance

3. Custom Search Settings > AJAX results update when visitors click on the search button >> meaning i need to add button now ? cant use the same button for the archieve filter ?

4. filter editor

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="mysite_dist_search">
[wpv-control-distance compare_field="mysite-address" 
distance_center_url_param="mysite_maps_distance_center" 
distance_radius_url_param="mysite_maps_distance_radius" 
distance_unit_url_param="mysite_maps_distance_unit"]
</div>
[/wpv-filter-controls]
[wpv-filter-end]

5. Loop Output Editor >

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
    <wpv-loop>
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
[wpv-layout-end]

6 back to archieve page : add

<div class="mysite_dist_search">
[wpv-control-distance compare_field="mysite-address" 
distance_center_url_param="mysite_maps_distance_center"
distance_radius_url_param="mysite_maps_distance_radius" 
distance_unit_url_param="mysite_maps_distance_unit"]
</div>

after

[wpv-layout-start]

[wpv-items-found]

.

anything wrong here to highlight? thanks

#630660

1. create new view '> post type : i must select ? cant be auto detect ?
You must select the post type. The View is completely separate from the archive and it does not automatically detect what you want.

3. Custom Search Settings > AJAX results update when visitors click on the search button >> meaning i need to add button now ? cant use the same button for the archieve filter ?
You need to add the search button to this View. Remove all filters and buttons from the WordPress Archive's filter editor.

5. Loop Output Editor
In between the wpv-loop tags, add the post title, a map marker, or anything else you originally included in the WordPress Archive loop.

6 back to archieve page : add
No, don't add any filters to the archive. Delete all filters from the archive.