Taxanomies not showing up on CPT
-
Hi,
I have created 2 customs post types “Products” and “Services” and also created some custom taxonomies as well. I made both taxanomies and post types “hierarchical” and followed the tutorials. However, when I create a new post type, my taxonomies don’t populate on the right side as “select boxes” would do on a normal page.
Sorry I am new to this concept but I have another simple question. The purpose of creating “hierarchies” is to do custom queries for archive pages correct? what is the point of having a hierarchy for the taxanomies? only for better organizing them? or is there another reason?
Also, does it make a difference if I create the CPT first or the taxanomy first?
Many thanks…
-
For taxonomies, when you set them to be hierarchical, the metabox on the right should show nested checkboxes, much like you see with the default categories. If you set them to be non-hierarchical, then it’s just a text input with autosuggest built in from WP core.
If you’re looking at a taxonomy that has a select dropdown, then that may be a custom implementation.
Regarding hierarchies in general, that just means you can create parent/child relationships. For example with music you could have a taxonomy named “genre” and then a term named “rock”. Then, you find yourself needing more sorting, so you create a child tern named “classic”, and then “alternative”, and then “indie”. Each would get the “rock” term as its parent as they’re all derivatives.
The only place that order of creation matters, is if you’re wanting the post types to appear in a specific order in the menu, and by chance the “menu order” setting isn’t helping somehow. They get registered in the order they’re saved in, in our options setting and we just do a foreach loop over that. Taxonomies get registered first, and then post types.
Hi,
Actually I sorted it out. I had used same slug for both “Taxonomy” abd “CPT” which is “Products”, when I change the slug to “product_types” for the taxonomy, I was able to see them on the right side in the correct order.
Why doesn’t it allow us to use the same slug for both of them at the same time?
Also, when I create parent category “Parent 1” and Child category as “Child 1” url doesn’t reflect the nested structure. That means it looks like mydomain.com/products/parent-1 OR mydomain.com/products/child-1 even though they are nested! I would want the child post to look like this? mydomain.com/products/parent-1/child-1
Would that be too complicated?
Thanks…
Why doesn’t it allow us to use the same slug for both of them at the same time?
Probably internal query issues with WordPress core. I don’t have much of an answer beyond that. I also tend to try and avoid naming content types/taxonomies the same because of probably issues like that too.
Regarding the last part with permalinks, according to https://wordpress.stackexchange.com/a/17329/1006 we need to set “rewrite hierarchical” to true as well. We have the setting for that, it just defaults to false. So once both hierarchical and rewrite hierarchical are true, you should be good to go. I’ve tested this on my own and it worked for me for sure.
Hi,
Thanks for your answers. Actually, I had set up both of them to “true” but it still doesn’t work for some reason. Maybe I am doing something wrong, I will keep playing around and if no solution is found, I will share more details ??
It is weird because I do everything according to your plugin’s guidelines but keep getting those flat urls.
just in case it somehow hasn’t, visit your permalinks settings page just to clear that rewrite rules cache. Maybe that’ll help.
Otherwise, yeah just keep kicking the tires to see if anything changes.
Excellent. Thanks a lot.
Hi,
I have another question if you don’t mind ??
I have created custom post type called “Services” with an archive page “services” this CPT is hierarchical. I also created custom taxonomies (also hierarchical) such as “Service 1” and “Service 2” and so on. However, there are also some sub-categories for these as well, like “Service 1.1” “Service 1.2” etc..
Services (main archive page)
– Service 1
— Service 1.1
— Service 1.2
-Service 2
— Service 2.1
— Service 2.2Right now my archive page shows all custom post types that has been categorized as “Services” but on the main archive page, I just want to display the top-level pages and when I click those links, they will display their child items.
Thanks a lot.
When you say “archive page” do you mean a standard page named “services” and you’re somehow showing all the posts from the “Services” post type there? Clarifying this because there is the “has archive” setting that you can set to true, and then just go to mysite.com/my-post-type-slug/ and get an archive right away, no need to set up a standard page.
It sounds like you’re wanting almost like either what i’ll call a semi-visual hierarchy, or possibly just sub-archives. mysite.com/services/ shows just the post type posts with no parents, and then you click into a term archive? for a service 1/2/etc and only then show posts with the chosen child terms?
Something to keep in mind is that a permalink URL is telling WordPress what to query for. An easy example of that is when a post type slug and a page slug have a matching value. .com/services/. Is that a page? is that a post type? it may not know and if you find yourself in 404 errors, it may not be requesting the intended data.
At least as is, I’m wondering if the urls from your hierarchy idea above is going to be a mix of page and taxonomy terms or a post type and taxonomy terms.
Hi,
You are right, my permalinks have to be combination of page url’s and cpt slugs.
I have enabled the archive function for products and also filtered the top level posts on the page but I had an issue with it. I could only sort the posts either ascending or descending and I wanted to keep them in a specific order.
So I disabled the archive page, create a normal page as “products” and added some selection divs for each top level category while keeping the taxanomy in tact. So it looks like this. Products Page (9 different categories) I select a category and it would go to CPT archive page for that specific category. So I have the url structure I want and everything works fine.
Only thing I need to do is to place a seacrh/filter functionality on the archive pages (sidebar) and add ajax loading.
I am developing my skills as I am building this site and I wish there were more tutorials about the technical aspect of CPT’s.
Thanks for your help again.
Any parts needing my feedback/thoughts on? or are you kind of just laying things out for current status?
Probably experience more than anything, but the concept of post types are pretty straightforward, at least in my head. What is always the difficult part for people is how to potentially use them and the content published as one.
My question would be what type of things are you wanting to do that would involve the content saved as a post type?
Also the technical functionality permalinks tends to throw everyone off, especially at the start.
I build maybe 30 sites with just plain html, bootstrap, jquery. This is my first WP project. Although I understand the core concepts (and really like it) I don’t think it is the most intuative platform to use for beginers unless they are using stoc themes. I am using Genesis framework and modifying the sample theme, after 4 days of fiddling around, I just got a clear idea on how to do things ??
I found your pluging extremely helpful and thank you for that. If I have any questions, I will definitely ask ??
Cheers…
Sounds good, thanks @yucelm
Hello Michael,
I didn’t wanna create a new post for this but I have a quick question for you. I would appreciate if you could help me out.
I understand the point of creating hierarchical custom post types so we can have nested url’s.
What is the main reason/purpose or use case for creating hierarchical custom taxanomies? What is the benefit or advantage of it?
Thanks a lot in advance.
- This reply was modified 4 years, 8 months ago by yucelm. Reason: typo
Much of the same benefits and reasons as post types. Drilled down content classification and labeling and organization.
My preferred example is a custom taxonomy of “genre”. It could apply to movies and tv content types, or it could apply to music types. “Comedy” could be a parent genre, with “slapstick”, “romantic”, “improv”, “standup” all being child terms. Same with “Rock” being a parent genre and “classic”, “alternative”, “punk”, “emo” being child terms of that.
All depends on how you want to organize, itemize, and separate out content. I’d argue that the URL structure isn’t as much of a benefit as content organization is.
Hello Michael,
Hope you are doing well. I had a question for you and I would appreciate if you could help me out.
I have created my CPT “products” and my taxonomy “product_categories” then I set the taxonomy’s “Custom Rewrite Slug” as “products”
I have a static page named “products” with links to only my main categories.
When I click one of the links “Paints” it gives me“www.mysite.com/products/paints”
where all CPT’s with “Paint” taxonomy is visible, this is great so far.
The problem occurs when I click the individual product (single) n that page, it says “Not Found” and the url is “www.mysite.com/products/product-1”it should be: “www.mysite.com/products/paints/product-1”
I guess I need to set a re-write rules for this correct?
If so, can you point me out to the right direction?
I have searched on Stack Overflow and Google but none of the methods worked.
Many thanks in advance.
- This reply was modified 4 years, 2 months ago by yucelm. Reason: typo
- The topic ‘Taxanomies not showing up on CPT’ is closed to new replies.