Hello,
I have a comprehension problem when creating a query for a custom post type (=mitarbeiter) with a custom category (=abteilung). The custom category has subcategories and is hierarchical.
I am trying to create a query of the posts of the post type with a specific subcategory. The subcategory should be specified in the shortcode.
I understand the query of the post type and the category but have a problem with the definition of the query of the subcategory. Can you help me here?
<Loop type=mitarbeiter taxonomy=abteilung parents=true ??="{Get local=subcategory of taxonomy abteilung}">
?? = is that “category” OR “abteilung” (the name of the custom category)
I think this is more of a WordPress mix-up than an L&L mixup. The important thing to realize here is that a “custom category” is not the same thing as a “custom taxonomy.” A category is one of the default taxonomies in WordPress. So if you’re actually working with a “custom category,” that implies that your taxonomy’s data structure looks like this:
On the other hand, if you have a custom taxonomy that’s totally separate from WordPress’ category taxonomy, your data structure might look like this:
And then if you wanted to dynamically refer to the child term in your loop you’d just replace the value of the terms attribute with a local variable, as you sorta did in your example.
I hope that clears up the difference between a category and a custom taxonomy and based on which one applies to you you can choose the right approach above. I don’t think you’ll need to do anything fancy with parents=true or anything like that since it sounds like you simply want to display posts that have that child term applied, so the fact that it might be a child term of some other term doesn’t really matter at all since you’re ultimately just displaying posts that have a particular term applied.