Skip Navigation

[Resolved] Reusable View shortcode – how to

This support ticket is created 6 years, 9 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 7 replies, has 2 voices.

Last updated by Shane 6 years, 9 months ago.

Assisted by: Shane.

Author
Posts
#546919

I am trying to:
Create a view with query filter -> Taxonomy filter "Set by one View shortcode attribute" and here i want to set in shortcode to include category a, b but not c (post that are in category a and by but that has no category c selected)

eg. [wpv-view name="view-name" category="a,b,-c"]

but that not work.

I want to achieve something similar with:

query_posts( 'cat=1,2,-3' );

Is this possible? how can I achieve that using toolset.

Thank you!

#546979

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Felix,

So essentially you would want to do a filter for all the posts that are in A and B only correct? If a post is in A and B and C then it should not be included in the results correct?

Please let me know.

Thanks,
Shane

#547015

Correct.

#547022

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Felix,

In this case then you can use a custom view filter to perform this query instead of the shortcode attribute.

https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

If you're familiar with how wordpress query works then you can define your own custom query args and return it to the main query for views to filter.

Pretty much if it is possible with the WP_QUERY function then it is possible to do with this hook.

Please let me know if this helps.

Thanks,
Shane

#548631

Hi,

Thank you for the tip ... i was curious if i could achieve my objective in one step with query defined only by shortcode of a view without using a filter (sometime the filters are acting strange in this case - it does not work as it should).

To have a better understanding will explain you in detail my case. I have a collection of cars (this is a custom post type) which I categorise in several category - a, b, c, d which has a parent category X (a, b, c, d are subcategories of X). Also i have another category Y that has the following subcategories 1,2,3 and i put the cars in some of this categories too.
Than i want to list all my cars in several page filtered by subcategories of Y and sorted by subcategories of X. For that i use the following shortcodes:

1) For page that contain cars in subcategory 1 ? (that has parent category X)

<h1>a</h1>
[wpv-view name="name" category="a,-1"]
<h1>b</h1>
[wpv-view name="name" category="b,-1"]
<h1>c</h1>
[wpv-view name="name" category="c,-1"]
<h1>d</h1>
[wpv-view name="name" category="d,-1"]

2) For page that contain cars in subcategory 2 ? (that has parent category X)

<h1>a</h1>
[wpv-view name="name" category="a,-2"]
<h1>b</h1>
[wpv-view name="name" category="b,-2"]
<h1>c</h1>
[wpv-view name="name" category="c,-2"]
<h1>d</h1>
[wpv-view name="name" category="d,-2"]

... and so one

#548829

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Felix,

I see what you're saying, so you want to filter by one and sort by another?

Would it be possible to get access to the website to see a demo in action ? I can't say for sure if its possible or not unless i'm understanding the issue fully.

Thanks,
Shane

#548839

Hi Shane,

Yes i can get you access, here is your credentials and i give you administrator rol:

For the moment i find a solution by creating a custum taxonomy for "Y" category and subcategories "1,2,3,4"

This page is an exemple: hidden link
Here are other pages:

hidden link
hidden link
hidden link

It would be nice if i can do this without a custom taxonomy or supplementary filter.

#549607

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Felix,

Using separate taxonomies would be the best approach instead of one taxonomy with multiple terms.

We would eventually have to go there with the solution since you will have more control.

Thanks,
Shane

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