Home › Toolset Professional Support › [Resolved] Dynamic views?
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)
Tagged: Content Templates, Types plugin, Views plugin
Related documentation:
This topic contains 21 replies, has 2 voices.
Last updated by Bonnie 5 years, 10 months ago.
Assisted by: Nigel.
---- Tell us what you are trying to do? ----
I have two content templates - one to output categories (A-Z) and one to output items within each of the categories. It's quite simple.
hidden link
What I NEED to do is dynamically generate JUST the "A", JUST the "B" and so on.
E.g. a page like hidden link or something like that? Which would output just the following:
A
Access Management
---- Is there any documentation that you are following? ----
No, I can't find what I need and don't know what to search for.
---- Is there a similar example that we can see? ----
As above.
---- What is the link to your site? ----
hidden link
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
The WordPress way of doing this would be to create an 'az' taxonomy whose terms are A, B, C,... etc.
The when you visit a URL such as site.com/az/a it will display all posts with the taxonomy term 'A', site.com/az/b will list all posts with the term 'B', etc.
Although such taxonomy archives use URLs site.com/az/a, site.com/az/b, site.com/az/c etc., the taxonomy alone without a term (site.com/az/) isn't used, and so you can have a static page with that URL to display the complete list of posts, and still take advantage of the term archives.
This does require you to add az terms to each of the posts, it's not automatic, but does get round any possible gotchas such as "The Something" should come under 'S', should that arise.
So, to summarise.
Create an 'az' taxonomy with all the letters as terms.
Edit the posts to apply the appropriate letter term.
Generate the /az/ page itself as you wish. You can manually create it, or you can automatically generate it by creating nested Views. The outer one is a taxonomy View that queries the terms of the az taxonomy, so it will generate the letter headings. And a nested View will generate posts that correspond to each letter (have the az term set by the parent View).
You would then have your /az/ page, and the various sub-pages such as az/a/, az/b/ etc. (which are actually taxonomy archive pages).
If you need help with something specific, let me know.
Thanks, Nigel, for getting back to me.
I'm afraid I'm still really lost, though.
I had already done some of the steps in your suggestion before creating the ticket, but I'm getting stuck at a certain point.
I have created an "az" taxonomy already.
All posts were assigned to the correct taxonomy already.
It is the nested views I am struggling with. I am not sure of the steps I need to take to create this and then to generate the URL such as az/a, az/b and so on.
I'm just not sure where to start, sorry. 🙁
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
OK, you don't need to worry too much about the list of posts under a given letter, e.g. site.com/az/a to show all posts beginning with 'A', because if you have set up your data with an 'az' taxonomy then these URLs work automatically, they are WordPress taxonomy archives.
What we need to look at generating is the root az page which displays each letter (as a link to archive for that letter) as well as the individual posts for each letter.
For that we need two Views.
Let's start with the second one first. This will display the posts for a given letter.
So
- create a View to display the post type in question
- add a Query Filter for the az taxonomy where the term is set by the parent taxonomy View (see screenshot)
- output the post titles as links (using the wpv-post-link shortcode)
Now
- create the parent View, which will display terms of the az taxonomy
- for Query Options choose "Don't include empty terms", and order by term name, ascending
- in your output section output the term name (the letters) as taxonomy links, immediately followed by the child View you already created (each of which you can insert using the Fields and Views button).
So the key part of your output section will look something like this:
<wpv-loop> <h3>[wpv-taxonomy-link]</h3> [wpv-view name="az-posts"] </wpv-loop>
That should get the basics working, and then you can customise from there.
Thanks, Nigel.
I have followed your steps and created the views. These work fine when I include the view shortcode (for the parent view) within a page (this one: hidden link)
However, if I type in hidden link it doesn't take me to a filtered view just for the "As" - it takes me to the page for the first of the As instead. How would I get hidden link to display just:
A
Access Management
Acute Kidney Injury
Anti-Fraud Service
Does this make sense?
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
What is the slug of the taxonomy? "az-services"? I thought it was "az".
Maybe I could look at your site and I could see more readily what the problem is.
I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I can't see anything on the front-end to verify what I've found but...
...you had disabled the rewrite options for the A-Z taxonomy so the archive URLs were not as expected. I re-enabled them, and now the archive links would be site.com/az/a/ etc.
az is the slug of the taxonomy.
The answers I gave above assumed that you created a page with the same slug as the taxonomy, e.g. they would both have az as the slug.
The taxonomy doesn't use its own slug for the URLs except when used as a base for the taxonomy terms.
So if you edit the page so that it has the same slug as the taxonomy you will then have
- site.com/az/ -- this will display the list of letters with corresponding posts, i.e. the full directory
- site.com/az/a/ and site.com/az/b/ etc., which will display the results just for that letter.
(It doesn't matter if you change the slug of the taxonomy to match the page, or vice versa.)
Nigel, I am so sorry but I have read your post several times and still don't totally understand.
I have edited the page and given it the same slug as the taxonomy (az) but now when I go to hidden link I don't see a list of letters with corresponding posts, I just see a standard archive of posts.
And going to hidden link says "Sorry, nothing to display". 🙁
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
What do I need to be able to see anything on the front-end?
I can hypothesise and make suggestions but without being able to verify what shows on the front end I'm guessing somewhat.
Nigel, you don't have to do anything to view the front end. The links should work fine.
What issue are you seeing? Do you get an error?
Are you able to give me the IP address you are attempting to access this from and a rough time of the last attempt? Our server administrator has asked for this information.
This is what they said:
"There are no IP restrictions on this site. I have tested accessibility from multiple locations all with success. The only thing I can thing of is if he is being blocked due to Geo Location. His IP will help me track down any issues in the logs and work out where in the world he is coming from."
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I found one problem, namely that you had changed the slug used for the service post archive to 'az', which was preventing the page with a permalink of site.com/az/ from displaying.
I reset the has_archive option for the Services post type, and now the View you added to the page works correctly if you visit hidden link
However, the taxonomy archives are not displaying correctly at hidden link etc.
The URLs are correct. See my screenshot, which shows the list of az terms. If you hover over A, for example, you'll see that the View link leads to hidden link as expected.
But what I see when I visit that URL is the nothing to display message you see in the second screenshot.
That's not right.
I went back and edited your taxonomy and reset the settings to what they would be when first creating a taxonomy, and it still doesn't work.
I can't account for this last problem.
Before going any further I need to see if any other plugin or the theme is interfering. Is it okay for me to temporarily disable all non-Toolset plugins and to switch to a standard theme, e.g. twentynineteen?
Nigel, please feel free to switch themes and temporarily disable plugins, however the following plugin cannot be disabled:
As this will prevent you accessing the login screen.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I took a copy of your site to test locally because I was struggling to identify the problem, but after carefully checking all the options against the defaults I identified the problem as the exclude_from_search setting on the Services post type.
It doesn't sound like that setting should affect the taxonomy archive, but it does. I'm going to do a little further testing to check if this happens with WordPress anyway or occurs because of Types (I suspect the former, because Types uses standard WP functions to register types and taxonomies), but in any case it is now working on your site.
You can see your View working at this page: hidden link
I modified your View so that the letters are links, just to test they are working, which if you try them you should see that they are.
That's absolutely brilliant - thanks so much, Nigel. I would never have guessed that setting would impact on the display of the archive. Well done for identifying the issue!
I do have one further question, though (sorry): the archives at hidden link etc. are now displaying the right data, but not in the format I would like.
How do I now use Views to customise how the entries display in this archive view?