Skip Navigation

[Résolu] Filtering by Taxonomy / Unexpected Behaviour

This support ticket is created Il y a 9 années et 1 mois. 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.

This topic contains 5 réponses, has 2 voix.

Last updated by Wolf-Dieter Il y a 9 années et 1 mois.

Assigned support staff: Caridad.

Auteur
Publications
#75916

Hello!

I'm trying to filter a view by taxonomy, with "Value set by the current page".

Both page and type have a taxonomy, which works fine as long both have a value assigned.
For example, I use the taxonomy with value "homepage" on the homepage and also in the record I want to show > only the items with "homepage" are shown, not items with different taxonomy values.

But apparently, having an empty taxonomy on the page leads to all items being shown there… which was certainly not the idea behind the filter.

Any suggestions?

Thanks! Wolf-Dieter

#76364

Dear Wolf-Dieter,

Can you show me a screenshot of your filter to avoid confusion?

Regards,
Caridad

#76637

I'd like to do the following:
1_
> add a custom taxonomy to the pages of the site
> add a custom taxonomy to my custom post type "quotes"

2_
Show only the quotes…
… that have a non-empty custom taxonomy
… that have a custom taxonomy value = custom taxonomy on the page with the embedded view
… only on pages with a non-empty custom taxonomy.

Currently it works correctly as long as the page has a taxonomy value set. If not, ALL quotes are being shown. Which is not what I intended…

lg! Wolf-Dieter

#76922

Dear Wolf,

I believe this should work, let me consult the developers and I will get back to you.

Regards,
Caridad

#77071

Dear Wolf-Dieter,

This is by design. It works similar to the way the front end filters work. eg. if nothing is selected it displays all results.

You can wrap the View in a wpv-if and check the post taxonomy and only display the view if there is some taxonomy. Something along the following lines:

[wpv-if evaluate="!empty('[wpv-post-taxonomy type="your_taxonomy_slug"]')"]
[wpv-view name="The name of your view"]
[/wpv-if]

Let me know if you need help with this. Here is the documentation for shortcodes:

https://toolset.com/documentation/views-shortcodes/

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Caridad

Regards,
Caridad

#77382

Thank you! I get the point of the filtering behavior and it did the trick. As I'm using the shortcodes via do_shortcode in the sidebar, I ran into some troubles with the quotes/double quote but simply replaced the [wpv-if] with some php.