Skip Navigation

[Resolved] Is it possible to have nested views on Archive page?

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

Problem: I would like to group the posts in a post archive by taxonomy term.

Solution: It's not possible in a WordPress Archive, but you could use nested Views to achieve something similar. Pagination and post counts will not be consistently accurate, but if you simply want to show all the posts and terms on one page, this approach may work.

This support ticket is created 5 years, 12 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 romanA-2 5 years, 12 months ago.

Assisted by: Christian Cox.

Author
Posts
#1159673

I created a custom post type: "Rooms & Suites", with taxonomy "Room types". I have 3 Room types (A,B and C). Each Room Type can have many rooms. Finaly I need to show all the rooms, in the archive page of post type "Rooms & Suites" like this:

Room Type A
room 1
room 2
...
Room Type B
room 1
...
Room Type C
room 1
...

I think the above functionality refers to the "nested views". So can the Archive page of Rooms & Suites be formated this way?

#1159770

It's not possible to group a WordPress Archive of posts by taxonomy term directly in the loop, but you could insert nested Views in a WordPress Archive to achieve something similar. Leave the wpv-loop tags in the WordPress Archive empty. Insert the parent View of terms just before the wpv-loop tags. Insert the child View of posts in the parent View of terms, inside the wpv-loop tags.

There are several limitations with this approach. For example, filters, pagination and post counts may not work as expected in the WordPress Archive or in the nested Views. This approach works best in the simplest cases. More complex cases will require more complex custom code.

#1159790

Thank you Christian.
This is what I tried so far, but I would like to know if it was my best option or I was missing anything.
The limitations are not problem for me so this solution is ok. Finally, although I leave the loop empty, it is excecuted for every custom post type of the taxonomy. If I had 1000 records, would that be heavy or it has minor impact on server resources?

#1160038

If I had 1000 records, would that be heavy or it has minor impact on server resources?
I don't think it would be a problem, but unless you're using custom code, the maximum number of results shown on one page of an archive is 50. If you're concerned about performance, use the Pagination settings on the WordPress Archive to limit the number of results to a maximum of 1. This way the loop is only executed a maximum of once for each page of results. If you cannot see the Pagination settings in the WordPress Archive editor, scroll up to the top right corner and click Screen Options.

#1160564

My issue is resolved now. Thank you!