Skip Navigation

[Resolved] Alternative no-items-found

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

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 4 replies, has 2 voices.

Last updated by kemalS-2 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2087319

Hi,

I have a few filters set up to filter custom fields like "price".

But I wanted to ask if there was a possibility to not show the "No items found." message but posts that are closest to the entered value.

An example to understand this would be if the most expensive house is cheaper than the "minimum" typed price for the house of let's say $250.000 (Done with a "Number Custom Field" and a query of "equal or greater then"). So if the person who searched for $300.000 houses will still see all houses in descending order which would be in the case of this example $250.000 and down.

In my case, I list financial services and since Toolset doesn't support range sliders native I decided to use:

<div class="form-group">
<label for="wpv-wpcf-earning-potential">[wpml-string context="wpv-views"]Earning Potential[/wpml-string]</label>
[wpv-control-postmeta type="textfield" field="wpcf-earning-potential" placeholder="Expected $" url_param="wpv-wpcf-earning-potential"]
</div>

Its like a sorting condition if the filters return empty.

#2088045

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

There is no native way but you can customize it as per your need using the Toolset View's hook: wpv_filter_query
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
- Where you can fire a query before based on the price and check if it returns any value if no, then you can change the meta query value as per your requirement.

The above hook will fire before the view query fired.

There is another hook as well that if you would like to try: wpv_filter_query_post_process
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query_post_process
- Where this hook will be fired after the views query executed so again you should check if no posts are returned you should adjust your query argument for post meta value and fire a custom query and returned the posts.

#2088115

Thank you for this answer but I got another problem that has to do with views, I use bootstrap tooltips in my view but when I use Ajax refresh they break.

I tried adding:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
/**
* data.view_unique_id (string) The View unique ID hash
* data.layout (object) The jQuery object for the View layout wrapper
*/
jQuery('[data-toggle="tooltip"]').tooltip();
});

But it doesn't work.

New threads created by Minesh and linked to this one are listed below:

https://toolset.com/forums/topic/split-alternative-no-items-found-ajax-refresh-view-bind-javascript/

#2088183

Minesh
Supporter

Languages: English (English )

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

That is another issue. As per our support policy we entertain only one question per ticket. I'll split the ticket with your new question. You are welcome to close this ticket.

#2093987

My issue is resolved now. Thank you!