Sauter la navigation

[Résolu] Create page (view) of child posts sorted by hierarchical taxonomy

This support ticket is created Il y a 6 années et 8 mois. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Ce sujet contient 8 réponses, a 2 voix.

Dernière mise à jour par Luo Yang Il y a 6 années et 8 mois.

Assisté par: Luo Yang.

Auteur
Publications
#709802
system-state.JPG

I have 2 custom post types - Plants (slug: plant) and Complaints Treated (slug: complaint)
Complaints Treated posts are the children of Plants.
The Complaints Treated post has an hierarchical taxonomy : System/State (slug: system_state) with a sub-category Complaint, see screenshot.
For each Plant I would like to display its children (Complaints Treated) , I need to create a page of Complaints Treated (with Plant post as parent) sorted by the System/State taxonomy thus:

System/State.......................Preparation and Administration............Plant Parts Used..........Source

.....Complaints Treated

Cardiovascular

.....Heart Pain........................slug: prep_admin......................................plant_parts................source

.....Heart palpitations

.....High blood pressure

Dermatology

.....Eczema

Please could you give me a detailed explanation of how to set this up.

Thanks for your time
David

#712786

Dear David,

It needs a three level nested view, for example:
1) 1st view list top level terms of taxonomy "system_state", filter with:
Select taxonomy terms whose parent is None.
And display below 2nd view

2) 2nd view, list sub terms of taxonomy "system_state", filter with:
Select taxonomy terms whose parent is the value set by the parent view.
And display below 3rd view

3) 3rd view, list posts of post type "complaint", filter with:
Select posts with taxonomy:
"system_state" set by the parent Taxonomy View
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

in the single Plant post, you can display above 1st view

#714933

Hi Luo,
Thanks for your reply.
Would it be possible to give me an outline of the structure, as I understand it I would open a new page "Complaints Listed by System/State" This page would be based on a Content Template and the parent page would be the Plant page. You say I need to create 3 views, would these views be nested one within the other and are they referenced individually from the Content Template ?
Thanks for your help
David

#722643

Here is the outline of the structure, I assume you are going to achieve this:
Top term 1
-- Sub term A
---- Post one
---- Post two
-- Sub term B
---- Post three
---- Post four
...

Can you confirm that it is what you are going to setup?

First of all, Views is using WordPress class WP_Query to query posts in database:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
There isn't an option to use taxonomy to order the result, so in your case, it needs a nested view with 3 different views.

More help:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

#747024

Hi Luo,
Sorry been out of contact for a few days, but I'm back now.
Thanks for your reply about the Views which is very helpful, but I also would appreciate help from the stage of creating the page "Complaints Listed by System/State" which is based on a Content Template and the parent page would be the Plant page. I don't want to use Toolset Layouts so the 3 nested views would be referenced from the Content Template - is this schema of the page correct?

Thanks for your help
David

#747077

Yes, the Layouts plugin is not required.

You can create a content template for the single "Plant" post, and display the 1st view in the content template:
https://toolset.com/documentation/user-guides/editing-view-templates/setting-view-templates-for-single-pages/

And you can add a post type relationship filter in the 3rd view:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
Then it will output only the child "complaint" posts of current "Plant" post

#755521

Hi Luo,
The Plants page has a link to the Complaints page - the "Complaints Listed by System/State" for this plant appear on a separate page, who's parent is the Plant page. So would I put the 1st view in the Plant content template or in the "Complaints Listed by System/State" content template?
If possible could you give me an outline of where the content templates and each of the 3 views should appear.
Also please could you explain where I find the option: "Select taxonomy terms whose parent is None."

Thanks for your help
David

#758032

ok, I've got the 1st and 2nd views set up - still working on the 3rd 'cause I'm not seeing: ""system_state" set by the parent Taxonomy View"
Just want to be clear, I have 2 separate pages "Plants"and "Complaints Listed by System/State", Plants page is the parent of the Complaints page - all complaints for the parent Plant appear on the Complaints page. according to this setup are the 3 views you specify correct ?
Thanks for your help
David

#764716

Yes, it is possible display the related child "Complaint" posts in the single "Plant" post, or in another Complaints page.
if it is the second case "in another Complaints page", you will pass "Plant" post ID as URL parameter to the target Complaints page, in this page display the same 1st view.

If you still need assistance for it, please provide a test site with the same problem, I can setup a demo for you.