Skip Navigation

[Resolved] Views dynamic Query

This support ticket is created 6 years 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 5 years, 12 months ago.

Assisted by: Nigel.

Author
Posts
#1152400
post radious.png

Tell us what you are trying to do?

create a view (back-end filter) to show all post as per this query
cutom field value>distance

created custom field address type address.
created custom field post-radious
how to create a view query as per following requirement:
post-radious>distance
***calculate distance from current user location to address (address field)

Thanks

#1152970

Nigel
Supporter

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

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

Let's put aside for one moment the known issues with using the current user location in backend Query Filters.

I think you have this back to front (post-radious > distance).

A Query Filter is something that is applied once, at the beginning of the query, to determine which posts match a condition, and in your example it's more like applying a different condition to every post.

It seems like we are actually talking about a distance filter (distance < post-radious), where post-radious comes from the field value of the posts being queried.

I checked with the Maps developer who said while it is currently not possible, it is technically feasible.

So, I could create a feature request for this, and if we see a lot of demand then it could make its way into development.

However, it seems a very niche request, I've never come across it, or anything similar before, so my instinct is that it wouldn't gain enough support.

So, I won't formally put it forward unless you insist.

#1153191

Hello Nigel

Any other solution?

I put condition in template for view. it works perfectly without pagination(no pagination)

[wpv-conditional if="( $(wpcf-post-radious) gte '[toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-location']' )"]
[wpv-post-title]
[wpv-post-link]
distance: [toolset-maps-distance-value origin_source='visitor_location' postmeta='wpcf-location']
[/wpv-conditional]

but there is issue with pagination pages created as per all records.

Thanks

#1153210

Nigel
Supporter

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

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

Unfortunately that can't work when it comes to the pagination.

The pagination is reported on the basis of the number of posts returned by the query.

You then choose not to display some of those posts, but the posts are still part of the results, even though you hide them.

About the best you could achieve would be to use << prev and next >> for the pagination rather than showing something like "Showing results 1-10 of 33 results", but each page of results might have a different number of posts. You perhaps wouldn't notice that so much if you were using infinite scroll.