Forum

Thread tagged as: Question

Categories - show selective ones

Hello,

I'm creating a blog category section to list a few specific categories. So I'm trying to display a list of categories but be filter which are displayed. I also then want to use a template where it displays the last post image from within that category.

Firstly is that possible? Should I be using perch_blog_categories over perch_blog_custom, and how do you filter the categories to only display certain ones?

Sarah Evans

Sarah Evans 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What factor are you trying to filter on?

The category title

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so you'd do something like

'filter' => 'catTitle',
'match' => 'in',
'value' => "This, That, The Other",

Thanks Drew, I have the below but I'm just getting a blank page (php error).

Anything obviously wrong?


<?php perch_blog_categories(array( 'template' => 'category_listings-13.html', 'filter' => 'catTitle', 'match' => 'in', 'value' => 'raw, soups, breakfast', )); ?>
Rachel Andrew

Rachel Andrew 394 points
Perch Support

What's the error from the error log?

Hi Rachel,

I've just updated to the latest version of Perch and Blog and it's now working (sorry I should have done that straight away).

However it's only returning the first value in the list.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are your category titles all lowercase like that? Have you tried matching against the slug instead?

I've just tried CatTitle with values as camel case and filtering by CatSlug.

The first in the list always works fine, I can reorder them and it always displays the first one correctly regardless what it's filtered by (slug or title)

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that sounds odd. I'll have to take a look into it.