Skip Navigation

[Resolved] Listing taxonomy terms and posts associated with those terms

This support ticket is created 3 years, 1 month 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.

Our next available supporter will start replying to tickets in about 1.41 hours from now. Thank you for your understanding.

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)

This topic contains 3 replies, has 3 voices.

Last updated by Saul Baizman 3 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2200015

Hi there,

My site has a custom post type named Resource. The Resource custom post type has a custom taxonomy named Curatorial Categories. The Curatorial Categories taxonomy has two custom fields: a checkbox (to display this category on the homepage) and a field into which a number can be entered to control the sort order of the categories (on the homepage).

Programmatically speaking, what I'd like to do looks like this: for each Curatorial Category flagged to display on the homepage, get a list of Resource posts in that Curatorial Category and display them. The output should appear as follows:

Curatorial Category A Taxonomy Name
Post title of Resource 1 in Curatorial Category A
Post title of Resource 2 in Curatorial Category A
Post title of Resource 3 in Curatorial Category A
...
Curatorial Category B Taxonomy Name
Post title of Resource 1 in Curatorial Category B
Post title of Resource 2 in Curatorial Category B
Post title of Resource 3 in Curatorial Category B
...
Curatorial Category C Taxonomy Name
Post title of Resource 1 in Curatorial Category C
Post title of Resource 2 in Curatorial Category C
Post title of Resource 3 in Curatorial Category C
...

I think I need two Views: one to iterate over the taxonomy terms in the category, and one to iterate over the posts in that category.

Can you offer some guidance about how to accomplish this?

Thanks.

Saul

PS. I'm using the older legacy plugins to create Views and Layouts (not Blocks).

#2200493

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2021-10-20 at 09.20.12.png

Hi Saul

Yes, you need two Views.

The outer View queries the taxonomy, and you'll add a Query Filter for the checkbox field (in the screenshot on my test site I have a Colours taxonomy and am filtering by a checkbox field "Is Primary"). Set the ordering by the custom field as required.

Then in the output section of this View you will insert a second View (you'll need to prepare it separately).

That View will query resource posts, and you add a taxonomy Query Filter where the term is "Set by the parent Taxonomy View", so that only resources with the "current" term from the parent View will be returned.

#2200507

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

As Nigel shared and as you already assumed that, yes, you will require two views and you need to use the nested views (view inside view). One view that should iterate through the taxonomy terms and another view that should iterate through posts of Resource post type.

Here is the Doc that you should try to follow:
- http://toolset.com/2015/07/how-to-group-posts-by-category/

#2201111

Thanks, Nigel and Minesh. I really appreciate the screenshot and link. For anyone else who stumbles on this thread, another link that helped was this one:

https://toolset.com/documentation/legacy-features/views-plugin/using-a-child-view-in-a-taxonomy-view-layout/

Saul