详情页

zblog首页包含或不包含某些分类文章

时间:2023年09月19日

编辑:佚名

某些时候,会需要首页的文章列表显示或者不显示某些指定的分类。教程如下:
1、添加Filter_Plugin_ViewList_Core接口
点击复制代码 PHP
 Add_Filter_Plugin('Filter_Plugin_ViewList_Core','gamego_Plugin_ViewList_Core');
2、添加gamego_Plugin_ViewList_Core函数
点击复制代码 PHP
function gamego_Plugin_ViewList_Core(&$type, &$page, &$category, &$author, &$datetime, &$tag, &$w,&$pagebar){
    global $zbp;
    if ($type == 'index'){
        $ccc=array();
        $cid=(int)$zbp->Config('gamego')->proid;
        if($cid){
            $ccc[]=$cid;
            foreach($zbp->categorys[$cid]->SubCategorys as $categorynav){
                $ccc[]=$categorynav->ID;
            }
            $dd= implode(",", $ccc);
            $w[] = array('not in', 'log_CateID', $dd);
        }
    }
}
这里的案例代码我们用的是不包含某个大分类及其下属小分类文章的方法。也可以把not in改成in,改成仅包含。
扩展阅读,不包含指定的分类ID。
点击复制代码 PHP
function gamego_Plugin_ViewList_Core(&$type, &$page, &$category, &$author, &$datetime, &$tag, &$w,&$pagebar){
    global $zbp;
    if ($type == 'index'){
        $dd='1,2,3,4';
        $w[] = array('not in', 'log_CateID', $dd);
    }
}
扩展阅读的案例是首页列表不显示1,2,3,4这4个分类的文章。
相关文章
猜你需要