我正在使用 Perch CMS,其中我有一个自定义博客过滤器来显示同一类别中的相关帖子。我正在使用跳过模板不将当前帖子显示为相关帖子之一。
以下是我所拥有的,但我仍在显示当前的帖子。
鲈鱼文档:http ://docs.grabaperch.com/docs/blog/page-functions/custom/
<?php
$categories = perch_blog_post_categories(perch_get('s'), array(
'skip-template'=>true,
));
if (count($categories)) {
$cat_slugs = array();
foreach($categories as $cat) {
$cat_slugs[] = $cat['categorySlug'];
}
perch_blog_custom(array(
'filter' => 'postSlug',
'match' => 'neq',
'value' => perch_get('s'),
'category' => $cat_slugs,
'count'=>3,
'template'=>'blog/related.html',
'section'=>'Recipes'
));
}
?>
打印返回:
Array
(
[0] => Array
(
[image] => Array
(
[_default] => /perch/resources/img0178.jpg
[path] => img0178.jpg
[size] => 4555891
[bucket] => default
[w] => 4272
[h] => 2848
[sizes] => Array
(
[thumb] => Array
(
[w] => 150
[h] => 100
[path] => img0178-thumb@2x.jpg
[size] => 20250
[mime] => image/jpeg
)
[w725h483c1] => Array
(
[w] => 725
[h] => 483
[density] => 1
[path] => img0178-w725h483.jpg
[size] => 78864
[mime] => image/jpeg
)
[w50h50c1] => Array
(
[w] => 50
[h] => 50
[density] => 1
[path] => img0178-w50h50.jpg
[size] => 2137
[mime] => image/jpeg
)
)
)
[postID] => 28
[postTitle] => Butternut Squash & Tahini Soup
[postSlug] => butternut-squash-tahini-soup
[postDateTime] => 2014-04-24 09:01:00
[postDescRaw] => the content
[postDynamicFields] => {"image":{"_default":"\/perch\/resources\/img0178.jpg","path":"img0178.jpg","size":4555891,"bucket":"default","w":4272,"h":2848,"sizes":{"thumb":{"w":150,"h":100,"path":"img0178-thumb@2x.jpg","size":20250,"mime":"image\/jpeg"},"w725h483c1":{"w":725,"h":483,"density":"1","path":"img0178-w725h483.jpg","size":78864,"mime":"image\/jpeg"},"w50h50c1":{"w":50,"h":50,"density":"1","path":"img0178-w50h50.jpg","size":2137,"mime":"image\/jpeg"}}}}
[postTags] => Banana
[postStatus] => Published
[authorID] => 2
[sectionID] => 5
[postCommentCount] => 0
[postImportID] =>
[postLegacyURL] =>
[postAllowComments] => 1
[postTemplate] => post.html
[perch_image] => Array
(
[_default] => /perch/resources/img0178.jpg
[path] => img0178.jpg
[size] => 4555891
[bucket] => default
[w] => 4272
[h] => 2848
[sizes] => Array
(
[thumb] => Array
(
[w] => 150
[h] => 100
[path] => img0178-thumb@2x.jpg
[size] => 20250
[mime] => image/jpeg
)
[w725h483c1] => Array
(
[w] => 725
[h] => 483
[density] => 1
[path] => img0178-w725h483.jpg
[size] => 78864
[mime] => image/jpeg
)
[w50h50c1] => Array
(
[w] => 50
[h] => 50
[density] => 1
[path] => img0178-w50h50.jpg
[size] => 2137
[mime] => image/jpeg
)
)
)
)
)