Custom post types hierarchical relationships between posts types

This is my first post here after years of reading and solutions finding. Thank you!

I make a website for a personal project and I have problems with post relationships.

I want relationships between posts:
Band name parent post;
Album name child of band;
Song name child of album;
News child of band.
Common Taxonomy Geners
All posts are a separate custom post type.

Site.tld/album-name/song-name // is ok if has band name too

I know is very complex hierarchy, maybe I overt think it 🤔

I need a way to make relationships between these posts type, on front side, band name will be a post with description of the band, will show all albums of the band and news articles if they exist. Album post will have a description and all post with songs name…

A easy way will be to have Taxonomy band, and in the description of Taxonomy band description?

I try to find a plug-in that do this but no luck, no matter payd or free (one plug-in mb box pretend to do this but you need to buy several plug-ins…)

Thank you!

views – Pathauto alias full path for hierarchical taxonomy terms

My client has content tagged by a hierarchical taxonomy of arbitrary depth.

Currently the maximum depth is three, but that could change:

└── ChildTerm
    └── GrandchildTerm

Each Term has a unique TID (of course), but many Terms (especially descendants) share identical strings for Name.

However, the full Taxonomy tree path to each term is guaranteed to be unique (two adjacent Terms will never be identically named.)

All nodes tagged with GrandchildTerm of TID = 42 appear in a View at /taxonomy/term/42.

I would like to use Pathauto to generate aliases for each Term at the full taxonomy tree path, like so:


I was looking for Tokens to accomplish this.

I found instead that the paths are set by the View which generates the list of Nodes tagged with the Term ID.

The View has a contextual filter which accepts {{ arguments.tid }}.

Under Page Settings, the value for Path is /taxonomy/term/%.

Someone on this forum said setting up two contextual filters would help, but that does not apply here. I do not want /taxonomyname/taxonomyterm as the path; I want /ParentTerm/ChildTerm/GrandchildTerm as the path (or /tags/ParentTerm/ChildTerm/GrandchildTerm).

It is possible to set a contextual filter Content: Has taxonomy term ID (with depth) but I haven’t been able to get the path I seek this way.

Also, I would like a ParentTerm taxonomy page to return results for its descendants, but the current View only displays items for the specific TID. (The Views Tree module would help here, but it does not work with Drupal 9 yet.)

json – SQL for storing hierarchical data

I have a UX that is modeling a hierarchy. There is a concept of a section, a sub-section under a section, a panel under a section and a bunch of form-fields under a panel.

The UX exposes an ability to (valid-ly) reorder the hierarchy (move a panel to a different sub-section or a sub-section to a different section, etc.) and a save button that will save all of this in the backend.

My question is as to how do we store this structure while exposing a meaningful API.
My intuition is to continue to use SQL tables for each of these entities with appropriate FK’s.
However, since the save button saves the entire structure in one go, the backend would have to compare all the elements of this structure and update the appropriate entity rows. This for some reason feels “heavy” and something feels inelegant about this.

The other approach is to use a JSON store and just store and retrieve the exact structure, but I don’t want to lose the flexibility of being able to control each of the individual entities.

I am also constrained to using PostgresSQL.

Happy to add more details.

commerce – Using Simple Hierarchical or Client-side Hierarchical Select with conditional field

I am working on Drupal 9. I created a content type where I have to do a test to know the values obtained after a selection: As explained at the very bottom, if at the first level I select Printer and Network, I have to do a treatment appropriate, except that it doesn’t work at all.

How can I get the actual values selected for the test to pass?

If you have any other solution I am interested.

Using Simple Hierarchical or Client-side Hierarchical Select
with conditional field

  1. Create a taxonomy (Property Type) with 2 levels:
  • Printer
  • Laptop
  • Backup
    Tape Backup
    Tape Library

entities – Using drupal Simple hierarchical or Client-side Hierarchical Select with conditional field

I have been facing a problem for days without finding a solution and that is why I have come to present my problem here.
I am working on drupal D9 and I have created a type of content where I have to do a test to know the values obtained after a selection: as explained at the very bottom if at the first level I select Printer and Network I have to do a treatment appropriate except that it doesn’t work at all.
How can I get the actual values selected for the test to pass? If you have any other solution I am interested.
Thank you to all of you.

Using drupal Simple hierarchical or Client-side Hierarchical Select
with conditional field

  1. Create a taxonomy called ‘Property Type’ with 2 levels:

• Printer
• Local
• Multifunction
• Network
• Laptop
• Notebook
• Tablet
• Backup
• Tape Backup
• Tape Library

postgresql – Several Postgres partitioning questions (hierarchical partitioning, HASH, PK order)

I’m pretty new to Postgres and to RDBMS partitioning. I have a few related questions about the performance benefits of partitioning.

Background: I am trying to fix slow batch queries on a 4 column table with over 300 million rows. The PK is on all columns and the 3 columns that aren’t at the beginning of the PK also have single column indexes.

The indexes are growing out of control and are collectively larger than all RAM, and 3x the size of the underlying data. Batches regularly read and write a couple hundred million rows and they are slow.

What I have already done/understand: I’ve analyzed the code and determined that only the first and last columns are used in SELECT WHERE clauses. Other than INSERTs, no other queries hit this table (besides a DELETE that will be replaced with partition dropping). So I already know I can drop two of the three indexes since they are unused, which will lead to reduced index size, fewer indexes, and hopefully improved INSERT/SELECT performance.

In addition to dropping the unused indexes, I am going to use partitioning to replace a lengthy DELETE statement (which has a WHERE on the two middle columns) with, instead, LIST partitioning on those columns so I can DROP partitions.

Where I have questions: My proposed LIST partition also breaks up the table somewhat, so the partitions are no more than 1/4 the size of the original table. However, even that size is very large. I am considering adding a second hierarchical partition layer with a HASH partition on the 4th column, which could further considerably reduce partition size. My hope is that this would further reduce RAM consumption and/or improve performance in other ways.

However, I have a few questions about this:

  1. While I would be reducing partition size, my queries actually select on nearly every value in the column where I would be using HASH partitioning. I don’t know the distribution of those selected values, so there might be hot and cold partitions, but few totally cold partitions. In this case, would HASH partitioning even help, or would it be no improvement over the single level of partitioning? It’s kind of confusing to me, because since hashing is random by design, I would expect this to be a problem whenever HASH is used.

The only reason I think it might help is by reducing the height of the index trees, since the indexes exist within partitions. But all indexes would still be used. Basically what I’m wondering is, is it still an improvement to reduce index height even if all the indexes may be used, versus one huge index? Is there a best practice as to when HASH might help?

  1. The upper level of the partition hierarchy is a LIST on the two middle columns because that’s how my DELETE (that I am replacing) is defined. But those columns are never used in WHERE clauses. Is it a problem if the top partition hierarchy level isn’t even used in WHERE clauses? I could reverse the order so the HASH is the parent partition, since I actually select by that, but then I’d need to drop multiple child partitions when I DROP instead of one parent partition. Should I just bite the bullet and switch the order?

  2. Is it best for the order of the partition hierarchy to match the order of the PK? In other words, if my parent partitioning is LIST(col2, col3) and my child partitioning is HASH(col4), should I change my PK from 1,2,3,4 to 2,3,4,1 to match, or does it not matter?

Get the categories for a single post in a hierarchical way (category and his father)

I think the issue is quite simple but I can’t get it to work. I have a list of posts with a parent category and a child category.

What I want to do is to place in my posts the child category and the parent category separately.

<h1 class="title"><?php the_title()?></h1>
<h2 class="country">Parent category</h2>
<h3 class="city">Child category</h3>

How can I get it?

sql server – hierarchical data structure with MySQL

is they’r a way to order this table :

 | EMPNO  | MGR  |
 |7839    |NULL  |
 |7782    |7839  |
 |7521    |7839  |
 |7698    |7698  |

to be like this:

 | EMPNO  | MGR  |
 |7839    |NULL  |
 |7782    |7839  |
 |7698    |7839  |
 |7521    |7698  |

basically i want the hierarchical structure of employees data in mysql,
i already tried this query but it doesn’t give me the correct order or hierarchical structure i need
/*the query */ —->

LEFT JOIN emp E2          

javascript – Typescript type checking of hierarchical types

I want to create a hierarchy of Typescript interfaces because I think classes would be an overkill in my case. The main obstacle is checking if an object has a specific type. I solved it this way:

enum AnimalId {
  Mammal = 1,
  Fish = 3,

interface BaseAnimal {
  id: number
  categoryId: AnimalId
  name: string

interface Fish extends BaseAnimal {
  categoryId: AnimalId.Fish
  fins: number

interface Mammal extends BaseAnimal {
  categoryId: AnimalId.Mammal
  speed: number

type Animal = Fish | Mammal

const fish1: Fish = {
  id: 1,
  categoryId: AnimalId.Fish,
  name: 'trout',
  fins: 5,

const fish2: Fish = {
  id: 2,
  categoryId: AnimalId.Fish,
  name: 'salmon',
  fins: 8,

const mammal1: Mammal = {
  id: 3,
  categoryId: AnimalId.Mammal,
  name: 'lion',
  speed: 80,

const animals: Animal() = (fish1, fish2, mammal1)

/* eslint-disable no-case-declarations */
for (const animal of animals) {
  let score = 0
  switch (animal.categoryId) {
    case AnimalId.Fish:
      score += animal.fins
    case AnimalId.Mammal:
      score += animal.speed

There are two things I don’t like with the current approach:

  1. I have to create a Union type Animal with all specific Animal types. I would rather just use BaseAnimal instead.

  2. If I want to create a new specific Animal e.g. of type Fish I also have to set categoryId: AnimalId.Fish. It would be great if this is done implicitly:

const fish2: Fish = {
  id: 2,
  name: 'salmon',
  fins: 8,

MS SQL Server – How to create a view using hierarchical query

I would like to create hierarchical query using with and removing 4 join, someone can help please i am beginner in SQL views.

coalesce(d.C_ID, coalesce(c.C_ID, coalesce(b.C_ID, 
coalesce(a.C_ID, t.C_ID))))
from tablex t LEFT OUTER JOIN tablex a LEFT OUTER JOIN tablex b 
LEFT OUTER JOIN tablex d ON c.Title = d.C_ID ON b.Title = c.C_ID 
ON a.Title = b.C_ID ON t.Title = a.C_ID

content of Tablex is :

enter image description here

and the Result of 4JOINs and what i expect with CTE is :

enter image description here