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

Forum

Thread tagged as: Question, Blog

Perch blog multiple categories

Hi, I've created two category sets for blog posts: type (blog category by default) and language (a new set).

I want my client to have to diferent selects for both sets, for then display a blog custom post list filtering multiple categories, by a type and language. I am trying with:

perch_blog_custom(array(
    'filter'     => 'fecha-inicio',
    'value'      => $eachYear,
    'template'   => 'proyectos-list.html',
    'sort'       => 'postDateTime',
    'sort-order' => 'DESC',
    'category'   => $categoriaProyecto,
    'language'  => array($lang),
));

How can I do this? Thanks!

Raul Serrano

Raul Serrano 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The category option needs to be an array of the categories you wish to filter by. There is no language option.

Ok, but 'language' is my category id and category set slug.

Then, according to http://docs.grabaperch.com/docs/categories/filtering/ I should use it as:

perch_blog_custom(array(
    'filter'     => 'fecha-inicio',
    'value'      => $eachYear,
    'template'   => 'proyectos-list.html',
    'sort'       => 'postDateTime',
    'sort-order' => 'DESC',
    'category'   => array('categories/$categoriaProyecto', 'languages/$lang'),
));

and

<perch:categories id="categories" set="blog" label="Type" />
<perch:categories id="languages" set="languages" label="Languages" />

but it does not work...

how do I display an array of categories with variables?

Drew McLellan

Drew McLellan 2638 points
Perch Support

'category'   => array('categories/$categoriaProyecto', 'languages/$lang'),

should be

'category'   => array("categories/$categoriaProyecto", "languages/$lang"),

Drew, that way prints posts for any of those categories, but what I need is to show post with both categories at the same time... Is there any way for doing that ( & operator?)

Thanks!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Use the category-match option

 'category-match' => 'any'

or

 'category-match' => 'all'

Thanks Drew!