Forum

Thread tagged as: Question

Content Custom show two filters in results.

Hi there.

I'm using content custom to bring in some content from another page and separate the results based on a filter. However, with some of the results I'd like them to feature on other pages using a different filter i.e have a folio item that appears on both a web design service page and an illustration page (if it features it)

Currently using this to bring in my results, which all works fine.

        <?php $opts = array(
        'template'=>'homepage-work.html',
        'page'=>'/graphic-design-portfolio.php',
        'count'=>4,
        'filter'=>'category',
        'match'=>'eq',
        'value'=>'illustration',
);
perch_content_custom('Folio Work',$opts); 
?>

it's the addition of a second filter that I'm having trouble with, From the content_custom page on the perch I thought I could do the following and add in a second filter using an array. but I'm not getting any results doing the following... anyone have any clues what I'm doing wrong? or even if it's possible

    <?php $opts = array(
        'template'=>'homepage-work.html',
        'page'=>'/graphic-design-portfolio.php',
        'count'=>4,   
        'filter'=> array (
        array(
        'filter'=>'category',
        'match'=>'eq',
        'value'=>'illustration'),

        array(
        'filter'=>'category2',
        'match'=>'eq',
        'value'=>'illustration'
        ),
     ),
);
perch_content_custom('Folio Work',$opts); 
?>

Many thanks in advance

Nik Gill

Nik Gill 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

<?php $opts = array(
    'template' => 'homepage-work.html',
    'page' => '/graphic-design-portfolio.php',
    'count' => 4,
    'filter' => array(
            array(
                'filter'=>'category',
                'match'=>'eq',
                'value'=>'illustration'
            ),
            array(
                'filter'=>'category2',
                'match'=>'eq',
                'value'=>'illustration'
            )
    ),
);
perch_content_custom('Folio Work', $opts); 
?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm presuming these aren't real categories, but just a field you've created called category and category2.

No, they're just placeholders to test...

But... I've actually solved my problem in the meantime... I neglected to add the 'match'=>'or' after my arrays, when I did, everything popped into place where it should.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, great.