Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Konrad Pilch
Konrad Pilch
2,435 Points

Custom Post Type Taxonomies/Categories

Hello There!

I did struggle with this for several days now, and I feel I'm coming closer to it!

Yet, there's a big barrier to make it work how it should, I feel I'm almost there, but still quite far.

Here are the screenshots.

The categories are taking the articles form the default post type in WP. As you can see I have only two names there, they are very long, in different category, which they work.

Now, theres Articles highlighter, and if I go on that page, you can see i have articles with categories and there are lots of them, thats what i need to display, not defualt WP articles.

I did set taxonomy as in the pictures etc..

I currently have archive-article.php which i think works when i hit the preview on the CPTu

Here are the pictures, they might not be in order but hopefully they are good enough.

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

This looks like this is working correctly, what are you trying do exactly?

Konrad Pilch
Konrad Pilch
2,435 Points

Well, it doesn't seem for me to work correctly, I think I'm getting it somewhat.. but i think it's a mess that needs to be cleaned up. Not to mention i go up and forward with the names and the taxonomies , the build one etc.. it's hard to clean this.

This is what im trying to do :

Well, so you have a Custome Type named Articles, where you write about different programming topics, like HTML, CSS, PHP etc..

You have 7 articles in PHP, 4 in HTML and 12 in CSS. They all show on page-articles. Now, when you click the category, it will need to show only the category. Right now, I know how to make this if i used the wordpress default posts, which we can see that it works..

but i need to categorize them not with posts, but articles.

So here are the SS

This is the wordpress default posts http://imgur.com/VvCXO1z

ANd this is what i need to make it so it's default http://imgur.com/JbthfZY

With the code i have and stuff set up, it shows me this http://imgur.com/IrfA3MK whcih in reality comes from this but i need it to come from this http://imgur.com/JbthfZY which in reality is this

Kevin Korte
Kevin Korte
28,149 Points

Okay, so use your category-$slug.php template, and use the WP Query for the article post type.

Konrad Pilch
Konrad Pilch
2,435 Points

That doesn't work. When i click on the category, it leads me to archive.php and displays all the posts from articles. When I add the Wp query, same thing.

if i add a category.php or category-$slug, it has no effects what so ever.

Konrad Pilch
Konrad Pilch
2,435 Points

Actually, isn't this the stuff i should do? https://www.advancedcustomfields.com/resources/taxonomy/

Bit complicated, hard to get my head around this, since there are soo many ways, and soo much to this category/taxonomy whatever.

Kevin Korte
Kevin Korte
28,149 Points

Well, that would be a new piece of info. Are you using ACF taxonomies, or are you using wordpress's default taxonomies? That would change the answer.

Konrad Pilch
Konrad Pilch
2,435 Points

I don't know, it's soo messy : d

Im using ACF taxonomies

Konrad Pilch
Konrad Pilch
2,435 Points

Yeah, I'm using "ACF taxonomies" , and I'm sturgling to make when click on a specific category to show it up.

I jsut tried to follow the documentation, but gosh, soo messy in my mind about this stuff. I managed to do WP defautl stuff, but now the cat works with the acf uhhhh

It's just confuses me really bad. I have named many names for the template. I have followed the hierachy, but i don't know what is it that i shoudl do , taxonomies.php? cateogyr.php? archive is the default of them , but i will have a separate archive page for 2015, 2016.

Well, all im trying to say that i tried so many thing, and im having hard time to see this in one piece now.

Kevin Korte
Kevin Korte
28,149 Points

when you're adding taxonomies on your admin dashboard for a post, what does it look like?

Kevin Korte
Kevin Korte
28,149 Points

I had to go back and look at ACF taxonomies. Wp is going treat the built-in wp taxonomies like categories and tags, different than it will the ACF taxonomies.

WP taxonomies are going to follow the template heirarchry, and I suspect this is what you want. If you wanted a page that showed all article post types with an html category, you would want to use the built in wp taxonomies.

ACF taxonomies are for special circumstances. Like wp taxonomies, you can loop through, filter, and search for posts based on an acf taxonomy, but it won't change the template heirarchy. This is really good when you don't want a category to mess with the template logic.