We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Problem, Blog

Can't get perch_blog_categories() to filter by section

I have this code:

    'section' => $sectionSlug,
    'cache' => false,
    'sort' => 'catTitle',
    'sort-order' => 'ASC'

and am expecting it to only show categories that are in use by posts in the $sectionSlug section, but instead all categories are returned.

Am I expecting the wrong thing or making a mistake somewhere?

Perch: 2.8.4, PHP: 5.4.26, MySQL: 5.5.34, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.4), assets (2.8.4), categories (2.8.4), perch_blog (4.6), perch_forms (1.8.3)
Kirk Roberts

Kirk Roberts 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Categories don't have sections themselves - what you're looking for doesn't exist.

Thanks for the reply... I see in /perch_blog/runtime.php that 'section' is an option parameter in the $default_opts for the perch_blog_categories() function. What is that supposed to do?

The categories are all in the 'blog' set. I was assuming that setting the section would mean that only categories in the 'blog' set which were applied to posts in the specified section would be returned.

The goal is to have essentially two discreet blogs on the same site, with separate categories and tags. I was hoping that sections would accomplish this. If I'm barking up the wrong tree please let me know! (And if Perch Runway can solve this with Collections I'm open to that... but I also need to be able to import the two blogs from Wordpress.)

Drew McLellan

Drew McLellan 2638 points
Perch Support

The default option doesn't do anything - it's just there to prevent errors.

At the moment there's no way to split a single category set based on section.

Okay, thank you for the clarification. I'll see about writing something custom.