Skip Navigation

[Resolved] Search Filter no more works

This support ticket is created 4 years, 11 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
- 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)

This topic contains 7 replies, has 2 voices.

Last updated by Nigel 4 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1412527

I am trying to
Given a maximum budget value i would search between 2 values

Location max cost
Location min cost

While in the new version of toolset it stopped working because in query it adds the name of the parametric search as wpcf-name of the field in the html box

#1412529

wpcf-costo-a-persona does not exist as custom fields but in the query it adds automatically it to the wp query

( mt3.meta_key = 'wpcf-costo-a-persona' AND mt3.meta_value = '20' )

i just need to set this custom value to search between max and min

#1412531
Schermata 2019-12-17 alle 01.33.00.png

this is written in search output:

[wpv-control-postmeta display_values="Costo Massimo,10€,15€,20€,25€,30€,35€,40€,50€" values=",10,15,20,25,30,35,40,50" field="wpcf-costo-a-persona" type="select" source="custom" url_param="wpv-wpcf-costo-a-persona"]

and the image is how i setted the filters.

the query is this:

SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) INNER JOIN wp_postmeta AS mt3 ON ( wp_posts.ID = mt3.post_id ) WHERE 1=1 AND (
wp_postmeta.meta_key = 'wpcf-importanza'
AND
(
( mt1.meta_key = 'wpcf-costo-minimo' AND CAST(mt1.meta_value AS SIGNED) >= '20' )
AND
( mt2.meta_key = 'wpcf-costo-massimo' AND CAST(mt2.meta_value AS SIGNED) <= '20' )
AND
( mt3.meta_key = 'wpcf-costo-a-persona' AND mt3.meta_value = '20' )
)
) AND wp_posts.post_type = 'location' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 DESC

#1412991

Nigel
Supporter

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

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

Can I clarify what you are trying to do here?

You have one single custom field "costo-a-persona" that you want users to be able to search for by setting a minimum value and a maximum value, is that correct?

Your View looks more complex than that, because you appear to also have custom fields "Costo Minimo" and "Costo Maximo" and so I want to be clear on what you are trying to do before going any further.

Also, could I please have your debug info? hidden link

#1413097

Hi, it is not so...
Since it is not possibile to search for repeating fields and show the post but only the repeating fields i created 2 Custom Fields:

- Maximum Price
- Minumum Price

I want user to search for their maximum budget so "maximum budget" is a number between Minimum Price AND Maximum Price

"Maximum Budget" is not a custom field but just the name of the parameter of the search form

#1413269

Nigel
Supporter

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

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

"Since it is not possibile to search for repeating fields and show the post but only the repeating fields"

I don't understand what that means.

Do I undertand what you are trying to do correctly?

You have a custom field for minimum price and a custom field for maximum price. You want to filter by both of these fields, but you only want one filter control—for their maximum budget—and both query filters should take their value from this one filter control. Yes?

The problem looks like you are adding a filter control for a field "wpcf-costo-a-persona":

[wpv-control-postmeta display_values="Costo Massimo,10€,15€,20€,25€,30€,35€,40€,50€" values=",10,15,20,25,30,35,40,50" field="wpcf-costo-a-persona" type="select" source="custom" url_param="wpv-wpcf-costo-a-persona"]

But wpcf-costo-a-persona is not the field you are filtering by, and it is being included in the SQL query.

I suggest you delete your existing filter controls and query filters and start again.

Then insert a filter control for one of the fields you do want to filter by, say, the minimum price.

This will use a particular URL parameter. You can change the URL parameter added with the filter control to something more generic, e.g. wpv-costo, and edit the existing Query Filter for the minimum price so that it takes its value from that URL parameter.

Then insert a second Query Filter, this time for the maximum price, and set it to use the same URL parameter (and the required condition, e.g. less than or equal to).

#1417769

Ok not that's ok
I have to submit a bug... while editing wizard filter it inverts display_values and values in the output shortcode.

Another question ?
It initially worked also for custom get parameters like mine (wpcf-costo-a-persona) what appened now ? It adds this search value in query also if it was not in the filters

#1417891

Nigel
Supporter

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

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

Screenshot 2019-12-20 at 09.07.53.png
Screen Shot 2019-12-20 at 09.00.52-fullpage.png

I don't know if I have misunderstood you, but I just set up a test site with the scenario I described in my last update and it worked correctly.

I've attached a screenshot of the entire View settings so that you can see how it works.

I'm querying the Items post type which has custom fields min-price and max-price.

In the Search and Pagination section I have inserted a filter control for the min-price field, where I have changed the label to say "Budget" and changed the URL parameter to wpv-budget.

The Query Filter corresponding to the wpcf-min-price field uses the same URL parameter.

I then added a second Query Filter for the wpcf-max-price field which also uses the same URL parameter, the only difference being the math comparison.

So on the front end this displays one filter control "Budget" that adds a URL parameter wpv-budget when applied, and the View has two Query Filters which listen to this URL parameter to provide the values for the wpcf-min-price filter and the wpcf-max-price filter.

You can see the results in the second screenshot where I'm searching with a budget of 20 (note the output of my View which displays min-price | budget | max-price).

If this isn't what you are aiming for I will need a more complete description of what you are trying to do.