[Closed] Reusable View shortcode – how to

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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

This topic contains 7 replies, has 2 voices, and was last updated by  Shane 2 months ago. The support staff assigned to this topic is Shane.

Viewing 8 posts - 1 through 8 (of 8 total)
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
Forum moderator

Supporter languages: English (English )

Supporter 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
Forum moderator

Supporter languages: English (English )

Supporter 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://wp-types.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
Forum moderator

Supporter languages: English (English )

Supporter 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: http://av.prearechin.ro/wp-admin/post.php?post=40&action=edit
Here are other pages:

http://av.prearechin.ro/wp-admin/post.php?post=4083&action=edit
http://av.prearechin.ro/wp-admin/post.php?post=4090&action=edit
http://av.prearechin.ro/wp-admin/post.php?post=4087&action=edit

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

#549607

Shane
Forum moderator

Supporter languages: English (English )

Supporter 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

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘[Closed] Reusable View shortcode – how to’ is closed to new replies.

Known issues and their solutions

We document known issues and their solutions in Toolset erratas. Save time by checking there first and seeing if what you are facing is a known issue. This list is kept short. We do our best to resolve all known issues with every release of Toolset plugins.

Support Policy

Toolset staff will help you use the Toolset plugins correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

For more information, read our full Customer Support Policy.

Need custom programming work for your site? Check out our certified partners.