Skip Navigation

[Resolved] multiple filters don't work

This support ticket is created 3 years, 8 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
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: Africa/Casablanca (GMT+01:00)

This topic contains 14 replies, has 2 voices.

Last updated by Eugene Mednikov 3 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#2024577

I've got a view with lots of filters:
hidden link
hidden link
hidden link

Custom fields are defined in the same way: checkbox, store 1 when checked, nothing when unchecked

For some reason, only one of 5 checkbox fields is filtered properly (accepting credit). All others are simply ignored.

I've tried to enable views debug mode, but it doesn't seem to work after filtering, only on page start.

Toolset is the last version (just updated).

#2024945

Hello and thank you for contacting the Toolset support.

Did you have the option "checkbox, store 1 when checked, 0 when unchecked" for the fields before? If yes, it is possible that the database still holds 0 for unchecked options, which will give unexpected results. You will have to visit post manually and save them again to remove the 0. Please check with one post or two to see if that's the cause.

Otherwise, I'll need to take a closer look at the view to analyze it. I'll also need to have some test scenarios as I wouldn't be familiar with your data model or probably the language.

If the view is using AJAX, the debug popup will only open on the initial page load, we'll need to disable AJAX while investigating the view until we fix these issues.

Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2026043

Thank you for the credentials, I confirm they work for me. I have visited the existing views and I assume that you are talking about this one right? hidden link

Please tell me where in the frontend it is being used/tested? I can scan for it and I see it used in several pages and one content template. Can you tell me which one are you working in to be sure we are talking about the same page. Please provide a URL.

I'll also need a test scenario that demonstrate the issue, I am sure you will understand that It would be hard for me to guess:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead, I get xxx

#2026057

hidden link

here you can see it live

and yes, the view is 437. And I think the most important question now is why does it lose parameters at filters?

#2026059

Can you elaborate more about this why does it lose parameters at filters? ?
Can you please explain it in steps like this:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead, I get xxx

In the meantime, the query filters seem to be corrupted. Check this screenshot hidden link

#2026061

Go to filters, set a parameter (like at template), save, reload: and it's empty again

Delete one of these filters, save, reload: and it's back

#2026091

Would it be possible to take a copy of your website or work on a staging site? I would like to debug the view while WPML is deactivated.

#2026095

hidden link

I'll check regarding staging copy

#2026133

The link that you have shared in this reply is in the English language, does the view work as expected in the original language?
https://toolset.com/forums/topic/multiple-filters-dont-work/#post-2026057

If the view works as expected in the original language, and does not work correctly in secondary languages, it means that the view works correctly, but the filters are not translated correctly.
The fields are not translated and are not copied to other languages. Check this screenshot hidden link
When the staging site is ready, let's configure one field to be copied(2nd option), save a couple of posts, and check if they work as expected.

If the view does not work as expected in the primary language, we'll disable WPML until we fix it, then we'll check the secondary language.

#2026139

It doesn't seem to work in any language. I've asked for a staging copy meanwhile...

#2026147

Thank you. Let me know when the copy is ready. I am setting your next reply to be private to let you share the credentials of the staging site safely.

#2027689

At first, I thought that the issue is caused by a weird custom field query that I am not used to. Check this screenshot hidden link
Usually, it is the message we output for Text search, performed against the title, the body, and custom fields(using Relevanssi plugin). But it does not appear inside the custom fields query filters. I assume that this view was built with an old version of the plugin and its settings are somehow corrupt. I can't tell more without accessing the database.

So, I created a new view on a new page to test the filters hidden link
And it turns out that the issue is caused by WPML shortcodes inside the filter shortcode attribute:

title="[wpml-string context='gtm']Prepaid card[/wpml-string]" 

When the filter contains this WPML shortcode in the title attribute, it gets ignored by the view. Like if the user did not check it at all. If we remove this title attribute, the filter works as expected. And I can confirm it in the underlying SQL query from the Views debug tool.

I am not sure if it is a new bug introduced in the last update or an exception that appears only on your website. I need to test in a clean installation. If the bug is confirmed, I'll escalate it to the developers. If it is not, I'll need to take a copy of your website to escalate the issue with it.

I the meantime, I would like to test the view again on the branches page, you will get duplicate posts across languages because WPML is not activated yet. hidden link
You can reactivate the theme and other plugins if you like, but it is better to let them deactivated until we fix this issue, and for performance reasons.

If you confirm that the view filters posts as expected, please activate WPML plugins again and check it in the other languages. Let me know what you will get.

#2029377

Indeed, without [wpml-string] is seems to work. Although I see this weird last filter that cannot be removed:
hidden link

If I remove the last field from the filters template, then it's removed from this list, and the new last one looks like this. Also 'AND/OR' switch seems to be missing.

I did it at production already:

<div class="breanches-filtr-check">
<div class="form-group">
[wpv-control-postmeta field="wpcf-russian-speaker" type="checkbox" title="Service in Russian" url_param="wpv-wpcf-russian-speaker"]
[wpv-control-postmeta field="wpcf-accessible-branch" type="checkbox" title="Accessible" url_param="wpv-wpcf-accessible-branch"]
[wpv-control-postmeta field="wpcf-open" url_param="wpv-wpcf-open" title="open"]
[wpv-control-postmeta field="wpcf-star" type="checkbox" title="Favorite branch" url_param="wpv-wpcf-star"]
[wpv-control-postmeta field="wpcf-accepting-credit" type="checkbox" title="Accepting credit" url_param="wpv-wpcf-accepting-credit"]
[wpv-control-postmeta field="wpcf-prepaid-card" type="checkbox" title="Prepaid card" url_param="wpv-wpcf-prepaid-card"]
</div>
[wpv-filter-spinner spinner="/wp-content/plugins/wp-views/embedded/res/img/ajax-loader3.gif"][/wpv-filter-spinner]
</div>

#2031029

My apologies for the late reply, but I do not work on Wednesdays and Thursdays.

I confirm that this is a bug in Toolset, and I have escalated it to our 2nd Tier user for another review. I'll get back to you as soon as we have any information to share.

Now, please reactivate WPML, and test the view in other languages, so we can work on it if the search does not work as expected. Let me know what you will get.

#2032575

It seems to work with WPML as well