Skip Navigation

[Resolved] View determined by URL parameter, would like title to also use URL parameter

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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by juliaM-5 6 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#629437

After going back and forth on whether to use the wp archive or a custom built View to display artwork according to the art category taxonomy, I settled on the custom view. Essentially working, but I am struggling to access the information passed in the URL to further refine the view(s).

You'll see three area's where I want information displayed: The title (art category), the description (which is in the taxonomy definition), and the art category echoed in the title in the sidebar where artists are listed.

How do I recall the wpvartcategory that is passed in the URL?

Link to a page where the issue can be seen: hidden link

#629489

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Julia

The wpv-search-term shortcode can be used to retrieve any URL parameter: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term

The documentation describes using it with the default 's' search parameter, but you can specify any parameter you want.

#629824

Thanks Nigel,

That's getting me closer. However, I'm still not able to snag the description from the art-category taxonomy. I've tried variations on this idea to no avail:

[wpv-layout-start]
	[wpv-items-found]
<h1 style="text-transform:capitalize;">[wpv-search-term param="wpvartcategory"]</h1>
Art Category description here, if it exists: [wpv-post-taxonomy type="art-category" id="$[wpv-search-term param="wpvartcategory"]" format="description"]
<div class="artwork-column">
	<!-- wpv-loop-start -->...
#630029

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Julia

This

[wpv-post-taxonomy type="art-category" id="$[wpv-search-term param="wpvartcategory"]" format="description"]

says show the description of the art-category term applied to, not the current post in the loop, but the post which is parent of the current post of the post type specified by a URL parameter.

Is that what you intend?

I'm not sure you can set the id attribute using a shortcode, but I'm not sure if that's your intention, so let's clear that up first.

#630175

Yipes! If you're reading my intent from my code, we're both in trouble! 😉

If you look at the page I referenced earlier, hidden link, you'll see that I've now got the 'Jewellery' references for the title and sidebar heading. Thank you.

Following the title in the main content area, you'll see my placeholder text "Art Category description here, if it exists:" after which I'm endeavoring to see content of the description field for the art-category 'jewellery'. Make sense?

Basically, this is content that is part of the title block, in that it is outside of the loop. It refers to the taxonomy that relates to the posts listed in the loop.

#630928

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Julia

This turns out to be frustratingly difficult, and so I'm not surprised you have had problems.

When outputting taxonomy terms and their fields, there are shortcodes where the taxonomy comes from those assigned to a post (e.g. wpv-post-taxonomy), and shortcodes where the taxonomy term is the current object (e.g. wpv-taxonomy-field), such as when you have a View which queries taxonomy terms and iterates over them, rather than the conventional posts View which queries and iterates over posts.

In your posts View in the Loop Output section you can use wpv-post-taxonomy to output the term description, which it takes from the current post in the loop (which must, because of your query filter, have the term assigned).

But if you move that shortcode before the Loop, the context is no longer a matching post, but the page where the View is inserted, which doesn't have the taxonomy term assigned.

In which case, you would need to create the right context. I would say here that you need to create a second View, this time a View which queries your art category taxonomy, and which uses the same URL parameter (wpvartcategory) to specify the term, and then in the output section you can output whatever details you like from that taxonomy term, including its description.

But. Your post View filters the taxonomy term slug according to the URL parameter, whereas the filter in a Taxonomy View filters the term ID with a URL parameter. You can't use the same parameter for each, your link to this page would have to include two parameters, one that specified the term as a slug, another that specified the same as a term ID.

You could do that and it will work.

An alternative would be to make a duplicate of the View you already have, using the same Query Filter, but adding a limit setting of 1 (so that only one post is returned). Output your taxonomy fields, including the description, using wpv-post-taxonomy inside the Loop Output section. So the description will be output only once.

Then insert this View into your first View, before the Loop Output section.

Slightly contrived, but either of these methods should work.

#631225

Thanks Nigel, while waiting, I waffled back to using the wp archive instead of view. If I find myself back at views again, I will try your alternatives here. As you say, somewhat contrived, but worth a shot!