Skip Navigation

[Gelöst] [Regression bug] Taxonomy filters not working on taxonomy archive pages

This support ticket is created vor 2 Jahre, 11 Monate. 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
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 11 Antworten, has 3 Stimmen.

Last updated by Francesco vor 2 Jahre, 11 Monate.

Assisted by: Jamal.

Author
Artikel
#2055735

Around 2 years ago we reported the following bug:
https://toolset.com/forums/topic/bug-report-with-fix-taxonomy-filters-not-working-on-taxonomy-archive-pages/
which was finally fixed on version Views 2.7.3.

Unfortunately, it seems that the fix was reverted and the bug reintroduced in the current version of Toolset Views 3.5.1 (or a previous one).
At the moment we applied the same temporary fix described in the previous ticket, but we would really appreciate it if you could fix it again.

Thanks.

#2056117

Jamal
Supporter

Languages: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

If I understand well, you have the following:
- A search view that has a taxonomy filter, inside a regular page.
- The view search form is used in a widget.
- The widget appears on all pages of the site.
=> But, inside taxonomy terms, the taxonomy filter does not offer all the terms, right?
I checked this scenario in a clean install and I was not able to reproduce the issue. Check this screenshot hidden link

You can log into my test site using this link hidden link
- The view: hidden link
- The archive template: hidden link
- The widget hidden link

Maybe, I missed something. Can you try to reproduce the issue on this test site? Please let me know what steps I might have missed.

If the issue is reproduced, I'll escalate to our 2nd Tier. If it does not, we can assume, it is an exception that appears only on your website. In that case, we'll need to take a copy of your website and debug it.

#2058793

Hello Jamal,
thank you for your prompt reply. I have recreated the bug on your test site.
Please check this page hidden link and in particular the filter at the top (not the one in the footer widget).
By the way, you can find the fix in the aforementioned ticket.
Further note: the issue affects both selects and radio buttons.

Thank you.

#2059389

Jamal
Supporter

Languages: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Thank you for your report, but that's not actually a bug. That is expected behavior. You have added a taxonomy filter to the archive template. This filter will provide all the possible values when visiting the post-type archive page, which is in this case the homepage(the blog archive).

However, it won't work for archives of the same taxonomy. We just can't filter a taxonomy archive with the same taxonomy terms. That's how the archive templates work.

I hope this answers your question. Let me know if you have any questions.

#2063829

Hello Jamal,
thanks for your reply. I understand your point but in our use case we have multiple taxonomies related to the same post type, and it would have been handy to use the same archive template for all of them so that searches can be performed from everywhere on the site.
Would it be possible for you to add a filter hook so that we can customize this behavior without affecting the native functionality of the plugin? It would only require you to add a couple of lines of code in the plugin (this is needed for both selects and radio buttons).
Thank you.

#2064031

Jamal
Supporter

Languages: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Thank you for your feedback. I do understand your point of view, but that not as easy as it appears. Otherwise, that would already be implemented.

I would suggest wrapping that taxonomy filter inside a conditional block. The block can use the is_tax taxonomy function from WordPress to hide it when it is being used inside a taxonomy.
https://developer.wordpress.org/reference/functions/is_tax/

Please note that you will need to register the function to be used inside conditions.
https://toolset.com/documentation/programmer-reference/views/using-custom-functions-in-conditions/

#2064151

Hello Jamal,
while I still think it's a bug, as it was classified such by your team on the previous aforementioned team 2-3 years ago, I fear you did not fully understand our need.
We need to display some items (missing terms of a taxonomy search filter) that your plugin hides, not vice-versa. So using a conditional block is useless for our need, as we need to show something that is missing and not to hide something that appears.

On the other hand, adding a filter hook on your side would cost you very little effort, as it would be a matter of modifying two lines of code on your plugin, without affecting the native functionality (even if you don't consider a bug).

Please note we are long-term professional WP plugin developers ourselves, so we know what we're talking about.

Specifically, this is our proposed modification:

In file plugins/wp-views/embedded/inc/walkers/wpv_walker_taxonomy_radios.class.php
(and similarly in file plugins/wp-views/embedded/inc/walkers/wpv_walker_taxonomy_select.class.php)

change line 175 from

 if ( $this->in_this_tax_archive_page ) {

to something like this

 if ( $this->in_this_tax_archive_page && apply_filters( 'wpv_hide_terms_in_tax_archive', true ) ) {

I would really appreciate it if you could forward this to your dev team for consideration.

Thank you.

#2064259

Jamal
Supporter

Languages: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+01:00)

I am really sorry if I gave the feeling that I did not understand your request very well or if I don't take it seriously the way it should. I think I have understood your request.

while I still think it's a bug, as it was classified such by your team on the previous aforementioned team 2-3 years ago
The bug was about filters in a different view, that is being used inside an archive(in a core WordPress widget). I tried to reproduce it in my first reply https://toolset.com/forums/topic/regression-bug-taxonomy-filters-not-working-on-taxonomy-archive-pages/#post-2056117
This is totally different. You want to get terms inside a taxonomy filter. Which should work for every archive except that specific taxonomy. This is a current limitation and we do not have plans to handle it.

On the other hand, adding a filter hook on your side would cost you very little effort, as it would be a matter of modifying two lines of code on your plugin, without affecting the native functionality (even if you don't consider a bug).
I can't really comment on this, as it is out of my scope as a supporter.

I would really appreciate it if you could forward this to your dev team for consideration.
Of course. I'll check this with our 2nd Tier and get back to you.

#2064421

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

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

Hi Francesco

Let me step in here with some comments, please let me know your thoughts at the end.

First, the older ticket you linked to was about inserting Views with search filters on archive pages (possibly via a widget), whereas this thread if I'm understanding correctly refers to a custom archive with search filters, and that's what I'm addressing here.

If you have a taxonomy filter for, say, a colour taxonomy, on the post type archive the filter will include all available terms.

But if you use the same custom archive assigned to the colour taxonomy archive, when you visit the, say, archive for the red term, then the filter will only include the red term, the other colour terms are not included.

That is by design, because a custom archive with search works by adding filters to the main query, and on the archive for the term red that term is already specified in the main query, and you can't filter for blue posts on the red archive where the red term has already been set.

I think you understand this, but I'm repeating it for clarity.

Now, you say that you would want the colour filter to include all the terms, not just red, on the red archive.

The problem with your suggestion for modifying the plugin code is that it won't work.

Try it yourself.

I didn't add a filter action, I just used false for the purposes of testing:

if ( $this->in_this_tax_archive_page && false ) {

It does work inasmuch as all of the terms are then included in the taxonomy filter dropdown—but they don't work.

Choosing blue, for example, has no effect, the page updates and posts with the term red (from the current archive main query) are the posts which are returned.

And it is never going to work in the sense of trying to fight the main query.

What we've suggested in the past is that users replace the taxonomy "filter" on a custom archive for the same taxonomy with a list of links in a dropdown. Persisting with the colour example, on the red archive the dropdown would show red, blue, and green, but red would be inert (effectively already selected), while blue and green wouldn't filter the existing page but instead would be links to the blue archive and to the green archive respectively.

The drawback with such an approach is that if the user had already selected some other filters (e.g. custom field filters), then selected the taxonomy filter which navigated to another archive URL, the previously selected filter values would be lost, they would need to enter them again.

#2064453

Jamal
Supporter

Languages: Englisch (English ) Französisch (Français )

Timezone: Africa/Casablanca (GMT+01:00)

I hope that Nigel's explanation provides some insights into why this limitation exists.

Let us know your feedback.

#2064541

Hello Nigel and Jamal,
thank you for taking the time to provide a detailed explanation. I have really appreciated it.
I confirm you are right. I am sorry, but I was convinced that in that scenario Toolset Views could override the main WP query with a different taxonomy term coming from the filter, but that is not the case.
So, basically, the modification I suggested is useless, as it only makes the terms appear but not let them work as filters.

In conclusion, we have switched to a different solution to obtain a similar result, based on the same template but applied to the general CPT archive and not to taxonomy archives.

Thanks for your assistance.

#2064545

You can consider this issue resolved. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.