Forum

Thread tagged as: Question, Blog

List blog posts by sub category

Hi, how do you list blog posts in a sub category. For example, category 'products', sub category 'widgets' I want to list posts in 'widgets' using perch_blog_custom.

Jon H

Jon H 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Should just be:

'category' => 'products/widgets'
Jon H

Jon H 0 points

Tried that Drew. Doesn't work. Here's code...

perch_blog_custom(array(
  'set' => 'blog',
  'category' => 'products/widgets',
  'template' => 'productpage_post_in_list.html',
  'sort' => 'postDateTime',
  'sort-order' => 'DESC',
));
Drew McLellan

Drew McLellan 2638 points
Perch Support

What output do you get from debug?

Jon H

Jon H 0 points

SELECT idx.itemID FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' AND (idx.indexKey='_category' AND idx.indexValue LIKE 'products/widgets%' OR idx.indexKey='_category' AND idx.indexValue='products/widgets')
Jon H

Jon H 0 points

Any ideas Drew?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is it widgets or hta?

Try with blog:

'category' => 'blog/products/widgets', 
Jon H

Jon H 0 points

Brilliant! That works. Thanks Drew!