Home › Toolset Professional Support › [Resolved] Using Shortcodes to define results
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Content Templates, Custom search, Views, Views plugin
Related documentation:
This topic contains 25 replies, has 2 voices.
Last updated by Pete 4 years, 2 months ago.
Assisted by: Minesh.
Hi there,
We use for pages like this: hidden link
Filters in a View (see attachment) to specify the results as we need. Basically we have one View for numerous pages using this shortcode:
[wpv-form-view name="collections-sub" wpv-collection="glamping" target_id="self"]
[wpv-view name="collections-sub" wpv-collection="glamping" view_display="layout"]
We just adjust the URL parameter for collection, in this instance it is glamping. We have many Collections.
My question, why wont adding another element to this shotcode work?
Ideally I would like: [wpv-view name="collections-sub" wpv-collection="glamping" wpv-location="wales" view_display="layout"]
Please note the addition of: wpv-location="wales"
The result would be a collection of glamping, just for Wales.
I add the location filter to my View Query filter and it still wont work.
Wont Toolset see that we are filtering more than one thing?
Thank you.
Hello. Thank you for contacting the Toolset support.
I see what you are trying to do. You've added one more shortcode attribute using "wpv-location":
[wpv-view name="collections-sub" wpv-collection="glamping" wpv-location="wales" view_display="layout"]
But if you can closely review the screenshot you shared for query filter section:
=> https://toolset.com/wp-content/uploads/2020/08/1748713-See_here.png
you can easily notice that you have added the related query filter for the "wpv-collection" but it seems that you did not added related query filter to filter your view for the field "location".
Can you please make sure you have added the related query filter for your location field as well.
Hey Minesh,
Ok I have added this when we reworked the page, please see attached.
This the page: hidden link
So this code is used in the filter bar:
[wpv-form-view name="feat-loc-destin-pages" wpv-collection="glamping" wpv-location="wales" target_id="self" target_id="36480"]
Now it wont work.
It worked fine before I added: wpv-location="wales"
This my intial question, am I able to add more shortcode attribute?
Thank you.
Yes - that should work.
Can you please tell me what relation clause you want to apply between your shortcode filters. It should display the posts which has value assigned:
- glamping AND wales
- glamping OR wales
Can you please share problem URL where you added your view as well as access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
As I can see on the following page: hidden link
- You want to display just form and when we select the specific filters values - it should be redirected on the Search Result page as you already setup. In this case, all the filter values will be available with the form as you setup a "Search Result" page, your view needs to set to use the submit button
So, in this case you should setup your "Query Filter" to filter by URL Pram rather than shortcode attribute.
I've adjusted the settings for your view accordingly:
=> hidden link
Now, you just need to set your view's Query Filter to use URL param.
Hi Minesh,
Ok I can see what you've done...thank you. However, the filter on this page:
hidden link
Now shows every options, Guests for example. It shouldn't as visors can select lots of guest options that don;t apply to Glamping.
Also in Area, areas are shown in the filters that have no Glamping, this we can't leave.
No way round this?
I'm guessing not so our original way may be the only way which is a shame.
The thing is that when I setup a view's search form like this:
[wpv-form-view name="feat-loc-destin-pages" wpv-collection="glamping" wpv-location="wales" target_id="36480"]
Where we pass the collection and location, it does not return any result and if you keep the above shortcode on the following page:
=> hidden link
Then save the page after applying the above shortcode, one the frontend where search form displayed at top of the page:
=> hidden link
- You will not see any option to select as there is no posts matching available for collection and location values.
if you remove just wpv-collection shortcode attribute, it does work because there are posts where collection glamping is set but there are no posts when collection and location matches.
Hey Minesh,
yeah it's not right is it? I just changed the collection to wpv-collection="sea-views" in the shortcode, its not turning out the right results.
I may well just use as I was, which is pretty flexible.
Being able to use more than shortcode attribute would have been cool, however no big deal.
It was worth the ask and appreciate your time as always 🙂
I'm not sure how exactly your setup before but it that setup you think is flexible for you and matches your requirement - I suggest you should go with that.
My issue is resolved now. Thank you!
Hi Minesh,
Sorry, another question ref this please.
For this page: hidden link
I use: [wpv-form-view name="feat-loc-destin-pages" wpv-collection="glamping" target_id="self" target_id="36480"]
This works as it should on the page, but results not right.
And on this page: hidden link
I use: [wpv-form-view name="feat-loc-destin-pages" wpv-collection="dog-friendly" target_id="self" target_id="36480"]
This works as it should on the page, however results are not right.
Both use the same Results Page however this not right. On Results I'm using:
Filter: [wpv-form-view name="feat-loc-destin-pages" target_id="self"]
Grid: [wpv-view name="feat-loc-destin-pages" view_display="layout"]
Am I missing something on the results page?
Thank you.
Because - you added the search form without collection shorcode attribute on the results page.
Can you please share access details again because access details are automatically removed once you mark the ticket resolved.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
It was a hard to think about this solution but fortunately Toolset offers few sortcodes using which we can workaround this.
Can you please check the following view. To the "Search and Pagination" section, I've added the following conditions:
=> hidden link
[wpv-conditional if="( '[wpv-attribute name='wpv-collection']' eq 'glamping' )"] <input type="hidden" name="collection-filter" value="glamping" /> [/wpv-conditional] [wpv-conditional if="( '[wpv-attribute name='wpv-collection']' eq 'dog-friendly' )"] <input type="hidden" name="collection-filter" value="dog-friendly" /> [/wpv-conditional]
- As you can see we added condition where we are checking what shortcode attribute value is passed to "wpv-collection" and based on the value,if matches, we are adding one hidden field. If you do have plans to add more pages, you need to add more condition like this and setup the hidden field.
And on the result page where you are displaying the form - I've changed the shortcode that displays the form as given under:
[wpv-form-view name="feat-loc-destin-pages" wpv-collection="[wpv-search-term param='collection-filter']" target_id="self"]
- As you can see, we are assigning the URL param value that is fetched using shortcode [wpv-search-term] to the "wpv-collection" attribute.
Can you please confirm it works now as expected.
Hey Minesh,
Thank you. Yes I had noticed there are a ton of shotcode options, however none for this kind of instance.
Ok, I couldn't find in View 36515 where you ha d placed this code?
Also it's not working, tested on both pages and results aren't right.
For example: hidden link
Select 2 guests and Norfolk - there is only one place, it's bringing them all up.
Dog Friendly is adding none dog friendly places too.
Can you please check now: hidden link
I've created the following view:
=> hidden link
I've added the above view on your search result page:
=> hidden link
[wpv-form-view name="feat-loc-destin-pages-search-result" target_id="self"] [wpv-view name="feat-loc-destin-pages-search-result" view_display="layout"]
On your original view:
=> hidden link
Within the "Search and Pagination" section, I've added the following conditional statements:
[wpv-conditional if="( '[wpv-attribute name='wpv-collection']' eq 'glamping' )"] <input type="hidden" name="wpv-collection" value="glamping" /> [/wpv-conditional] [wpv-conditional if="( '[wpv-attribute name='wpv-collection']' eq 'dog-friendly' )"] <input type="hidden" name="wpv-collection" value="dog-friendly" /> [/wpv-conditional]
Can you please check now if it works as expected now. I can see when I selec 2 guests and Norfolk, it shows filtered results.
=> hidden link