Skip Navigation

[Resolved] View shortcode exclude argument

This support ticket is created 4 years, 5 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 4 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1996949

Tell us what you are trying to do?

I have a view which I intend to use for many use-cases and pass taxonomy arguments into the shortcode like so
[wpv-view name="resources" resource-cat="catname1,catname2" resource-tag="tagname1,tagname2"]

This works wonderfully. However, what is the best way to make this so that we can pass through an exclude argument like so:

[wpv-view name="resources" resource-cat="catname1,catname2" resource-tag="tagname1,tagname2" resource-cat-exclude="catname3" resource-tag-exclude="tagname3"]

It doesn't make sense to have to create many different views for many different selections, this is the best way I can see it being done so its strange this isn't something out of the box.

#1997087

Hello,

In above example shortcode you mentioned above, you are using attribute: resource-tag="tagname1,tagname2", so it has already excluded other resource-tag terms, so it does not make sense to add "resource-tag-exclude" attribute.

Is there any special reason?

#1997681

Yes, good question. Let's say I want to display two rows of resources:

Row 1 contains content from: "Category 1"

Row 2 contains content from: "Category 1" and "Tag 1"

Row 1 still would pull in similar content as Row 2 just because they're of the same category, but I need Row 1 to exclude anything from "Category 1" and "Tag 1". So it would be helpful to allow an exclude option here.

#1998529

Unfortunately, there isn't such kind of built-in feature with Toolset plugins, you might consider custom codes, for example, use wpv_filter_query to trigger a PHP function, and add custom taxonomies filters into your view, more help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters