Forum

Thread tagged as: Problem, Blog

Multiple blogs' post categories

Sorry – I'm still going with the multiple blogs thing…! I've got multiple blogs (one called 'resources', the other called 'blog'). Each has its own categories set. Is there a conditional I can use with perch:if to only use the 'blog' set on 'blog' blog posts and the 'resources' set on 'resources' blog posts?

Martin Underhill

Martin Underhill 5 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using different post templates for each?

Nope – the same template for both. Is that where I'm going wrong? Although is there a way to specify a certain post template in the perch_blog_post(perch_get('s')); call?

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you used a different template for each you could specify a different category set for each.

Good shout. Passing the template into the the perch_blog_post call would work. I can't quite get the right way of doing it though as my php chops are weak… This doesn't work:

perch_blog_post(perch_get('s'), [
  'template' => 'post.php',
]);

Can you see where I'm going wrong…?

This works:

perch_blog_custom(array(
  'filter' => 'postSlug',
  'match' => 'eq',
  'value' => perch_get('s'),
  'template' => 'post_resource.html',
));

The problem is, its still using the post.html rather than post_resource.html in the control panel, so I can't apply the 'resource' categories to the post as it only shows the 'blog' set's categories.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to set up multiple post types: https://docs.grabaperch.com/addons/blog/post-types/

Ah, ok. Is there a way to assign a default post type to the 'blog' blog and another default post type to the 'resources' blog? If 'blog' is the overall default, that means I'd have to change the post type for every 'resources' post.

Sorry to be such a pain on this one :o

It's ok for my own blog, but if I was to implement the same for a client I want it to be as option-free as possible for them :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, use the setting in the blog options.

Sweet! Where do I set the option…?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Go to the Blog app, then Blogs, then select your Blog.