Tell us what you are trying to do?
I have two taxonomies:
a. Main Topics taxonomy
b. Sub Topic taxonomy
I am attempting to have the sub topic taxonomy listed on what has been selected in the main topics taxonomy
Is there any documentation that you are following?
tried many examples all failed
Is there a similar example that we can see?
Have not found any
Can you explain where and how this should be displayed?
Is this happening in a View, with a Custom Search, or are we talking about WordPress Archives, or even single Posts?
This will be crucial to find the solution.
Are those taxonomies 2 different ones, or is it one and the same, with a hierarchical structure whereas you have parent and child terms?
If the taxonomies are 2 different ones, there is no possibility to somehow display them stacked in a certain related order, as there would be no relation.
If they are hierarchical, you can as example display the Terms, by hierarchy, ordered asc or desc, using this ShortCode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy
In a custom search a taxonomy can be shown with https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-control-post-taxonomy instead.
Both can be ordered, but both cannot relate to another, not connected Taxonomy.
Please let me know the exact circumstances of your goal.
This is in a view.
It is two separate taxonomies, both different. They both are assigned to one CPT. However, I'd like the following functionality to work....
Taxonomy 1
Option A
Option B
Option C
Taxonomy 2
Option 1
Option 2
Option 3
Then when I am assigning the taxonomies to a CPT, it will be assigned one or more in each Taxonomy. I am NOT using hierarchical with parent and child.
Example:
Post 1 will have Option A, B, 3 checked.
Post 2 will have Option A, 1, 3 checked.
Post 3 will have Option B, C, 2, 3, checked.
Post 4 will have Option C, 1 checked
I have the search set up to go by taxonomy 2, I'd like for it to look at Taxonomy 1 and list all taxonomy 2 that has taxonomy 1 enabled.
So the resulting list would end up something like this:
Option A - Option 1 (count 1), Option 3 (count 2)
Option B - Option 2 (count 1), Option 3 (count 2)
Option C - Option 1 (count 1), Option 2 (count 1), Option 3 (count 1)
Using a hierarchical with parent and child taxonomy will not work because there will be many overlaps in the child taxonomy.
What you could do is apply a Query Filter for taxonomy 1, since this filter will never be manipulated by the end user, but always should check for posts that have at least some terms of taxonomy one assigned.
Then, add a Custom Filter for the taxonomy 2, where the user can choose and search by terms.
This will in any case only show posts that have:
- the settings as applied by the end user in the custom search
- the parameters used by you in the Query Filters.
The Query Filter should look like:
Select posts with taxonomy:
"Your Taxonomy" in one of these: your-term-one, your-term-two
Of you cannot foresee all Terms that will be applied in taxonomy 1, you cannot use a Query Filter, because in a Query Filter you will have to pass the exact terms to check for (you cannot check if "it's empty)
But, you can instead of a Query Filter use a Conditional HTML where you merely hide all posts which are not having a Taxonomy 1 term assigned:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#one
This, together with the Custom Search for Taxonomy 2, should allow you to do what you described above.
Thank you but this does not work because this is showing the posts. I want to show the taxonomy 2 as a list under taxonomy 1.
You cannot have Taxonomy Custom Searches.
Hence this can be used only in a Post view.
You can thou list your taxonomy terms, instead of Post Title, as an example.
But to have a search, you need to query posts in the View
In the archives, you can have a search for a Taxonomy Archive, but actually, that is a post loop as well.
Unfortunately you cannot have Taxonomy Views with Custom Searches, but there are feature requests filed - which I upvoted for you.