Skip Navigation

[Resolved] Unable to call $GET value outside wpv-loop

This thread is resolved. Here is a description of the problem and solution.

Problem: I am using a custom search View with a URL parameter. I would like to access the value of the URL parameter in the View, either inside or outside the loop.

Solution: You can access a URL parameter using the Views shortcode wpv-search-term like this:

Course Category: [wpv-search-term param="coursecategory"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-214940

100% of people find this useful.

This support ticket is created 5 years, 10 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Elsie 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1212218

I am trying to: call the category name once to use as the page title. I can only call it from within wpv-loop, and then it repeats down the page for every entry. I'm using the $GET function to create the page

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

I expected to see: "Fiction Courses" at the top of the page

Instead, I got: "Fiction Courses" repeating down the page OR at the top, it just says "Courses" because it won't grab "Fiction" from the URL

#1212350

Hi, can you tell me more about how the page title "Courses" is displayed? Is it part of a PHP template, or built-in to your theme? Can you tell me more about what you mean by "I'm using the $GET function to create the page"?

#1212352

Sorry, I meant that I'm using the $GET function to call the category for the page (which creates the page for just that category). You can see it in the URL for the page: hidden link

I'm trying to figure out how to fetch that variable and make it a non-repeating value on the page. The page current says "Courses". You can see that the "coursecategory" value in that URL is "fiction". I'm trying to output "fiction" on the page but NOT inside the loop. I'd like it to output right before the loop. It seems like it should be possible.

I'm trying to make the title of the page refer to the category of the page.

#1212765

You can access a URL parameter using the Views shortcode wpv-search-term like this:

Course Category: [wpv-search-term param="coursecategory"]

That will work in a View, either inside or outside the loop. More information about this shortcode is available here:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-214940

#1212779

Thank you so much! That worked!