Forum

Thread tagged as: Question, Addons, Blog

perch_blog_custom filtering

  <?php    
    $opts = array(
    'category' => array('sue' , 'paul'),
    'sort'=>'postDateTime',
    'sort-order'=>'DESC',
    'template'=>'blog/latest-blogs.html'
    );
    perch_blog_custom($opts);  ?>

returns all post that are tagged "sue", "paul", and "sue & paul".

Is there a method to only get the posts tagged with "sue & paul"?

Sue Stewart

Sue Stewart 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Try

'category-match' => 'all',
 <?php    
    $opts = array(
    'category' => array('sue' , 'paul'), 'category-match' => 'all','sort'=>'postDateTime','sort-order'=>'DESC','template'=>'blog/latest-blogs.html');
    perch_blog_custom($opts);  ?>

Above is what I now have. I have one post tagged with both the 'sue' and 'paul' categories. With the above I get no posts. 'category-match' => 'all' , I get the post tagged with both tags and those with either. Is my syntax wrong?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does this make a difference?

perch_blog_custom(array(
    'category'       => array('blog/sue', 'blog/paul'), 
    'category-match' => 'all',
    'sort'           => 'postDateTime',
    'sort-order'     => 'DESC',
    'template'       => 'blog/latest-blogs.html',
));

This did not make any difference.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does debug output for your page?


SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_news_index idx JOIN perch2_news_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_news_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' WHERE 1=1 AND ((idx.indexKey='postDateTime' AND (idx.indexValue >= '2015-01-01' AND idx.indexValue <= '2015-12-31'))) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2015-04-02 13:48:00' ) GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 10 SELECT FOUND_ROWS() AS `count` SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0 Using template: /templates/news/this-years-news.html 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 'blog/sue%' OR idx.indexKey='_category' AND idx.indexValue='blog/sue') OR (idx.indexKey='_category' AND idx.indexValue LIKE 'blog/paul%' OR idx.indexKey='_category' AND idx.indexValue='blog/paul') GROUP BY idx.itemID HAVING COUNT(idx.itemID)=2 SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' AND idx.itemID IN (NULL) WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2015-04-02 13:48:00' ) GROUP BY itemID ORDER BY sortval DESC LIMIT 0, 10 SELECT FOUND_ROWS() AS `count` Using template: /templates/blog/latest-blogs.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

That all looks like it's working as it should be, which suggests something more involved.

What should I check?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure there's anything you can do immediately - I'll need to set up a test case and see if we can reproduce it here.