Asking a question and have given it some thought, can't see if it would work...worth an ask.
Say...we have one View that has a filter with various Areas,
The default is, all Areas are shown until you select other wise...like on this page: hidden link
Click the third filter Area, there are a few areas to select.
Using this View, I would like to create various pages for each Area in the drop down.
Rather than create several separate Views, with each filter pre set in Query Filter, is there a way of using one view and setting 'somehow' the Area to be pre selected for each page.
If above is true - you should create your view in classic mode (as using blocks filter by shortcode attribute is not supported as the moment).
Add a "Query filter" from the "Query Filter" section for your area custom filed and and set it to filter by shortcode attribute and the value should be "passedarea".
Well - I would like to know why you are using the filter and results now.
It seems we have misunderstanding with your requirement.
Using the following method:
- The following view will display posts belongs to term: devon
[wpv-view name="view-name" passedarea="devon"]
- The following view will display posts belongs to term: wales
[wpv-view name="view-name" passedarea="wales"]
Both above view should be added independently on the page (not within another view).
Is this not your requirement that you want to display your posts per term? If no: Please share more details with your requirement with test case example.
I would like to know how the location field is setup? is it setup as custom field or taxonomy?
And if its set as custom field or taxonomy - is the location field is setup per location? How we can not that on the following page we need to display only options belongs to norfolk with location dropdown?:
=> hidden link
The thing is that there is no way to add taxonomy filter based on the specific pages as by default taxonomy filter options are displayed based on the terms that is assigned to the currently displayed result set.
I still wonder how we can identify that if the page X is displayed then taxonomy filter Location should be displayed with set of options like(one,two,thee) and if the page Y is displayed then taxonomy filter Location should be displayed with set of options like (five, six, seven) where options are just shared here as example.
I did think it was a challenge and couldn't see how this would work.
For a further example, this site does what we would like...each page is set to a Destination..
hidden link hidden link
Of course each has it's own URL, they have a large number of pages that are like this.
So I guess, if there is no way of achieving this with one View...
Can I ask:
1- I can create a View for each, this will add about another 30 Views to the 20 we already have. Will adding so many Views to one site cause performance or speed issues?
2 - For each of these Views, I would like to use the same Location filter which has 'all locations'. Is there a way in Query Filter I can include all locations yet pick one to appear as default (first)? Then set a different one to appear first for every View I need to create.
Lets say you are on the following page:
=> hidden link
- So what you need to do is, you need to edit your default post type "page" from Toolset => Post Types => Edit "Page" post type and assign the "location" and "area" taxonomy to your page post type and save your "page" post type.
Then, edit the following page:
=> hidden link
- And assign the terms using "location" and "area" taxonomy which falls into norfolk.
And then, we can create a view and add a query filter to filter type view by taxonomy location using a page where this View is shown.
Does this sounds good? all you need to do is assign the taxonomy to your page post type and later edit your page and add the terms where page belongs to. You can run a test on test install and let me know if that helps? Maybe as you need to use custom search with "location" taxonomy as "location" taxonomy is added as filter, we need to use view's filter hook "wpv_filter_query"
If the above workaround could help - you can share a test site where I can setup a demo for you.
And I do not understand when you say "However you've lost me there with the rest". What you mean exactly.
Would you mind to share test site or I should setup for you and show you the demo but I would recommend that if you can share a test site which is 1:1 copy of your live site where I can play around and make changes.
*** 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.
So, what was I saying, as you can see with the following link:
=> hidden link
- I've set the "Location" and "Area" taxonomy to display with the page post type.
Now, when I edit the specific page, in this case "Norfolk Holidays" as given under:
=> hidden link
- You will see that taxonomy "Location" and "Area" are available on right panel from where you can set this page belongs to what area and what taxonomy.
Now, we can create a new view or use the existing view and change the query filter for taxonomy "Area" and "Location" and set the taxonomy filter option to "Set by the page where this View is shown".
This way we can identify that this page has to filter by this terms. Does this sounds good?
Yes the test site is prob best for this. I just hope I can replicate what you've done on the live site 🙂
I can see what you've done and sounds perfect.
So the end result will be a one View thats output will change, per page depending on what is selected in Area and Location?
If that's the case....you're a genius 🙂
So the end result will be a one View thats output will change, per page depending on what is selected in Area and Location?
==>
Yes - the end result will be a one view that will output the related posts belongs to terms selected from taxonomy "Area" and "Location" from the current page which you are displaying.
Would you mind to setup couple of pages with your desired "Area" And "Location" and send me the links of those couple of pages as
well as tell me what view I should use with those pages.
Can I use the following view with the example pages you shared?
=> hidden link