Skip Navigation

[Resolved] How can I show all the posts which are close to the logged in user using Maps

This support ticket is created 5 years, 6 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by puneetS-3 5 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1303313

Tell us what you are trying to do?
I would like to show all the schools (We have the address of all the school which is a product) which is in the radius of 30kms from the address of the currently logged in user. I have the address of the currently logged in user in the custom map field of user as "landmark".

You can see my filter here : hidden link

It doesn't seem to work.

#1303331
#1303477

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I've passed the landmark as given under:

[wpv-view name="recommendation-for-parents" landmark="[types field='landmark'][/types]"]

Can you please check now.

#1303571

Hey the code works.Thanks a ton.

I had one more question regarding this. I would like to sort it by closest distance to farthest. Is it possible ?

#1303645

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

#1303651

Yeah.It has just options ; Fixed, Visitor Location & URL parameter. Which one to use so I can plug Landmark in it.

#1303687

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

There is no such native option but I try to add the following code to "Custom Code" section of Toolset:

add_filter( 'wpv_filter_query', 'func_distance_filter_landmark', 99, 3 );
function func_distance_filter_landmark( $query_args, $view_settings, $views_id  ) {
    if ( $views_id == 1535 ) { // if it is specific view and by default
      
      $x = do_shortcode('[wpv-attribute name="landmark"]');
      $view_settings['distance_order']['center'] =  $x;
     
    }
    return $query_args;
}

Where we are grabbing the landmark shortcode attribute we pass to view and grab the value and assigning to distance order's center dynamically. Dose this works?

#1304781

No it doesn't seem to make any difference at all. I am still getting the same result.

#1305107

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Then there is no such feature available as you can see it offers the options - Fixed, Visitor Location & URL parameter.

You may file a new feature request using the following form:
=> https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

#1305147

Sure I will go ahead and do that. Thanks for all the help.