Skip Navigation

[Resolved] Using a View as a shortcode attribute

This support ticket is created 4 years, 8 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)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Shane 4 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#1547191

I have a view where I need to use a shortcode attribute to filter. So, I created another view that gives me what I need. When I add that to the first view it terminates the first view and only shows the second...

My View: [wpv-view name="first-view" brand="[wpv-view name='second-view']"]

The output on the page looks like this: [wpv-view name="first-view" brand="12,73,194,16"]

So the second view executes but the first view doesn't. Any idea why, and how to get both to execute?

#1547513

Shane
Supporter

Languages: English (English )

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

Hi Chris,

Thank you for getting in touch.

Its not possible to have a view as a parameter like this. The brand ID numbers are generated from ?

This seems better to be a nested view setup rather than passing the second view as a parameter, please provide some more details on what you're trying to achieve.

Thanks,
Shane

#1548381

Okay thanks.

I think what I would need then is a wrapper shortcode that would strip out duplicates.

I need to get the woocommerce taxonomy back (brands is the attribute). So I have the view that queries all products and the output is the brand ID (taxonomy ID). The only problem is that it outputs for each product, which means 20 duplicates for each brand ID.

Can I wrap this in a shortcode that will reduce the dupliactes and only output unique values?

#1548437

Shane
Supporter

Languages: English (English )

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

Hi Chris,

So you child view is being filtered by a fixed number of Brands ID ? Because you can just add a taxonomy filter to your products view and then set the fixed taxonomies that this view should return the products for.
What I see you're doing is filtering your child view by the Brand ID's when you can just add a filter for it and select the brands that you want to display products for.

Can I wrap this in a shortcode that will reduce the dupliactes and only output unique values?

I would not rule out the possibility of this but I would try other alternative methods first.

Thanks,
Shane

#1548709

The ultimate goal is filtering a taxonomy (brand) of products that are within a single category.

So I figure I need to get all products filtered by category. This gives me a reduced list.

Then I need to output the brand. This gives me a list of brands - but if there are 4 brands and 100 products I could potentially get each brand listed 25 times.

I need to go into a category and output all brands that are in that category (and child category) for the category's products. In the above example, it should output 4 brands.

Make sense?

#1549903

Shane
Supporter

Languages: English (English )

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

Hi Chris,

Now I fully understand. So essentially you can get your desired setup but rather than using your views like this.


[wpv-view name="first-view" brand="[wpv-view name='second-view']"]

Its best if you nest them. This means you will add your first view into your second view so your first view is filtered by the second view. For a tutorial on how to do nesting of your views please have a look at the link below.

https://toolset.com/documentation/user-guides/views/using-a-child-view-in-a-taxonomy-view-layout/

If there are any questions please let me know.
Thanks,
Shane