Skip Navigation

[Resolved] Between condition don't report any results

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

Our next available supporter will start replying to tickets in about 1.96 hours from now. Thank you for your understanding.

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

Last updated by francescoG-3 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#583288
Search result   Casasi Immobiliare.png

I am trying to: I have created a Custom Search with two Between condition.

Link to a page where the issue can be seen: hidden link

I expected to see: When I insert the values into the Between range (min and max) I expected to see the result with the post that have the value between the range.

Instead, I got: I receive "No results"

#583774

Dear Francesco,

Please check these in your website:
1) You are follow our document to setup the custom field filters
https://toolset.com/documentation/user-guides/front-page-filters/#wpv-control-set-item

2) In case there are other compatibility problem in your website, please deactivate other plugins and switch to wordpress default theme, and test again

3) If the problem still persists, please provide a database dump file (ZIP file) of your website in below private detail box, I need to test and debug it in my localhost, thanks

#584019

Thanks for the details, I can download those files, and I am trying to duplicate same problem in my localhost, will feedback if there is anything found.

#584073

Here is what I found,
In the view "Ricerca Widget", you are querying posts of post type "Immobili"
But there isn't custom field "prezzo" in the "Immobili" posts, you can simply display them with Views shortcode in a single "Immobili" post:
[wpv-post-field name="prezzo"]
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153270
It does not output anything.

Since the custom field "prezzo" is not created with Types plugin,
so I checked it in database, table "wp_postmeta", run below SQL query:
SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE 'prezzo'

And I get lots of result, for example:
meta_id: 6681
post_id: 648
meta_key: prezzo
meta_value: 250000.00

The post ID is 648, which isn't a "Immobili" post, I tried to edit the post 648, but I get this error message:
Sorry, you are not allowed to edit posts in this post type.
So the post 648 isn't a "Immobili" posts, it is a "revision" post, and your filter won't be able to work.

#584147

Can you try to use this shortcode?
[wpv-post-field name="prezzo_gruppo_prezzo"]

because the field "prezzo" is a subfield of "prezzo_gruppo"

#584669

If there is custom field "prezzo_gruppo_prezzo" in each "Immobili" post, then the view's between filter should be able to work, see the result in your website:
hidden link

Max (€): 190000
There are three items in the result.

And I checked view "Ricerca Widget" in my localhost, in section "Query Filter", there are two filters using same URL parameter name "wpv-prezzo_gruppo_prezzo_min" and "wpv-prezzo_gruppo_prezzo_max":
a) prezzo_gruppo_prezzo is a number between URL_PARAM(wpv-prezzo_gruppo_prezzo_min), URL_PARAM(wpv-prezzo_gruppo_prezzo_max)
b) prezzo_gruppo is a number between URL_PARAM(wpv-prezzo_gruppo_prezzo_min), URL_PARAM(wpv-prezzo_gruppo_prezzo_max)

It would conduct some unexpected result, I suggest you test the filter one by one, if you only need to filter by custom fields "prezzo_gruppo_prezzo", I suggest you remove the second filter, only keep the first filter

#584738

Ok, I'm trying to solve, but I have the same issue with the "area_mq" field....

#584740

So, if you put 1 into min and 190000 to max you have "no results"...

#584743

I suggest you remove the second filter, only keep the first filter
I have do that, and now the price filter work fine.

So, now remain to solve the issue with the "area_mq" filter....

#584775

For the second filter:
prezzo_gruppo is a number between URL_PARAM(wpv-prezzo_gruppo_prezzo_min), URL_PARAM(wpv-prezzo_gruppo_prezzo_max)

Same as above post:
https://toolset.com/forums/topic/between-condition-dont-report-any-results/#post-584073
You will need to make sure there is custom field "prezzo_gruppo" in each "Immobili" post, and the field value is satisfied with the condition you are searching.

I checked it in your database dump file, all the custom field "prezzo_gruppo" are using empty value. you can simple run below sql query in your database:
SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE 'prezzo_gruppo'

#584798

I have solved the issue about the URL_PARAM(wpv-prezzo_gruppo_prezzo_min), URL_PARAM(wpv-prezzo_gruppo_prezzo_max).

Now remain to solve the issue about the "area_mq" field filter

#584805

There are two filters in the view "Ricerca Widget" which is related with the "area_mq" you mentioned above:
I am not sure which one is you talking about:

a) area_mq is a number greater than or equal URL_PARAM(wpv-area_mq_min)
Please run below SQL query in your database:
SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE '%area_mq%'
There isn't any custom fields using meta key area_mq in your website
So it won't be able to work

b) prezzo is a number between URL_PARAM(wpv-area_mq_min), URL_PARAM(wpv-area_mq_max)
I think I have aleady answer it in above post:
https://toolset.com/forums/topic/between-condition-dont-report-any-results/#post-584073
But there isn't custom field "prezzo" in the "Immobili" posts, so it won't be able to work too.

I suggest you try to setup the filters one by one by following our document, make sure the existed one is correct and work, then setup another one.
https://toolset.com/documentation/user-guides/front-page-filters/

#584831
Modifica Immobile ‹ Casasi Immobiliare — WordPress - area_mq.png
Modifica Field Group ‹ Casasi Immobiliare — WordPress.png

So, the custom field should not be "prezzo" but "area_mq".... and "area_mq" exist, see the image that I have attached.

#585034

I checked again in the database dump file, same problem:
https://toolset.com/forums/topic/between-condition-dont-report-any-results/#post-584073
there isn't custom field "area_mq" in the "Immobili" posts, you can simply display them with Views shortcode in a single "Immobili" post:
[wpv-post-field name="area_mq"]

You will need to make sure there is custom field "area_mq" in each "Immobili" post, and the field value is satisfied with the condition you are searching.

#586704

So, I have solved the issue.
The problem was that it is not setted the "between" condition between min and max, but there was setted ">= min" and "<= max". I have modified the condition in "between" and now it work fine!