Forum

Thread tagged as: Question

Categories - control over what are checkable per post type

Hi Drew and Rachel,

Is there any control for what categories are displayed as checkable options when adding a post via a certain post type template?

A site I'm working on has around 150 categories and it looks a bit of a mess. Certain post types don't need them all to be displayed as only a certain selection will ever be checked for that type of post.

A bit of a long shot but I thought I'd ask.

Sarah Evans

Sarah Evans 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can split categories up into different category sets - although that would have an impact on how you filter with the categories on the front end.

Are your categories organised hierarchically, or is it one big flat list?

It's for blog app so the set is 'blog'

It's set up with sub categories, up to 3 levels deeps. Ideally I only need to pull in categories with the cat parent of 'x' and ignore 'y' and 'z' for this certain post type.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You don't need to stick to the blog category set - that's just a convenience. You can add multiple sets if you need them.

At the moment there's no way to filter within a set.

Ok, I could see how that would affect my filtering.

Are you then able to pull certain sets into post types rather than display all of them?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, you can create a template for each post type, and in that template you can declare a set on the perch:categories tag.

Thanks.

If you are filtering using perch_blog_categories will that only look at the 'blog' set?

Drew McLellan

Drew McLellan 2638 points
Perch Support

With perch_blog_categories() you can give a set option:

perch_blog_categories([
    'set' => 'cheeses',
]);