I have a support issue that I think belongs to this category, but I might be mistaken because it involves relationships and the metabox builder and several other extensions. So, please excuse me if I’m posting in the wrong area, and just give me the right directions.
What I am working with:
* Custom Post Type [lesson]
* Custom Taxonomy (hierarchical) [course]
* Custom Taxonomy (non-hierarchical) [section]
What I have so far:
Both taxonomies are showing up on the CPT add and edit page, and all function properly.
I then made a metabox with custom fields for the CPT with two fields to replace the default WordPress ones.
The two fields are and their types are:
1. Course (taxonomy)
2. Section (taxonomy)
Both have advanced custom attributes to permit adding new taxonomies and removing the default WordPress metabox.
What I would like to do:
Make it so that when I select a specific [course] on the [lesson] page, the [section] is filtered to show ONLY [section]s associated with that [course].
Because right now the [section] field allows me to select any item, regardless of its relationship to [course].
Other factors to keep in mind:
In this setup, I want to allow a [course] to have many [section]s, but a [section] should only be permitted to belong to one [course].
Can you teach me how to accomplish this, please?
taxonomy only supports to show the list of taxonomies with settings, not support filtering by another field's value.
If a section (s) only belongs to one course, I think you can add the section as sub-courses (hierarchical). Then use the field type
checkbox_tree to select a section base on a course.
Thank you for your reply. Your recommendation is ideal if I were only going to have a few courses and sections, otherwise the [course] admin page will be long and cluttered - since the parent/child categories are not collapsible or filterable.
This is because I am already using [course] to designate a subject and then a (child) course, something that I forgot to mention in my original post.
Therefore, to also nest the [section]s under [course]s would lead to something like this example:
It's not very practical long term, and it will not look nice at all in the admin area. Although, it would make queries much simpler and resolve my issue easily.
So I will keep your suggestion in mind for smaller projects where a
select tree would be practical.
But can you tell me if anything else I may have missed in MB relationships (or Meta Box in general) can help me accomplish what I want without causing a clutter in my custom post add/edit pages? Perhaps there's a better and more efficient way of working this out and setting relationships between (1) course subjects, (2) the actual courses in those subjects, their (3) sections and their (4) lessons?