I'm trying to pass multiple taxonomy term arguments through a single URL parameter, and I'm not sure of the syntax that's needed to accomplish this.
I have a link within single product page layout that is intended to link to a page with a view that is needed to be filtered by the taxonomy terms that are related to the particular product. I just need help setting up the href structure.
This is what I have so far:
href="/finish-gallery?finish-style=[wpv-taxonomy-id]"
Right now, it supports a single taxonomy term id, but I want to create a view that lists out all the taxonomy term ids that are tied to a product.
Hello,
You can setup the link as below:
href="/finish-gallery/?finish-style[]={!{wpv-post-taxonomy type='category' format='slug' separator='&finish-style%5B%5D='}!}"
Notice, "%5B%5D" in above codes are URL encoded of characters: []
It will be able to pass term's slug to target page "finish-gallery", in the post view of target page, you can setup a post view filter by the taxonomy slug, for example:
finish-style slug in one of those set by the URL parameter finish-style
eg. lien caché
More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy
separator (opt):
'string separator for multiple values'
Default value is comma followed by a space
For whatever reason, the taxonomy term filter, set by URL parameter, only lets me use IDs, and the "format" attribute, for the [wpv-post-taxonomy] shortcode, doesn't support "id" as a value. But you did answer my question, in that I needed the correct syntax in which to push multiple arguments through to my views' filters via a URL parameter.
My markup still involves the taxonomy view which outputs the following as the loop item:
<a href="/finish-gallery/?
<!-- wpv-loop-start -->
<wpv-loop>
finish-style%5B%5D=[wpv-taxonomy-id]&
</wpv-loop>
<!-- wpv-loop-end -->
"></a>
Is there even a way to set the taxonomy term filter to a slug? If so, I'd prefer not to have to use a view if I don't have to.
Thanks for the details, in your case, there is a easy workaround, you can create a taxonomy view to output the term's IDs, for example:
1) Create a taxonomy view "finish-style-ids":
- Query terms of taxonomy "finish-style"
- Filter by:
Taxonomy is set by the current post
- In section "Loop Editor", within shortcode <wpv-loop> ... </wpv-loop>, display the term's IDs like this:
...
<wpv-loop>[wpv-item index=1]finish-style[]=[wpv-taxonomy-id][wpv-item index=other]&finish-style[]=[wpv-taxonomy-id]</wpv-loop>
...
- Enable option "Disable the wrapping DIV around the View" , this will be able to remove extra HTML div tags.
2) Use above taxonomy view to output the link, like this:
href="/finish-gallery?[wpv-view name='finish-style-ids']"
Then test again
I had already figured out a way to incorporate the taxonomy term id into a view loop, prior to your latest post, simply because the [wpv-post-taxonomy] shortcode doesn't support taxonomy IDs as an output type. I just needed the syntax for passing multiple filter arguments through a URL parameter, which you did in your initial post.
Thanks for your assistance!