GetList获取的文章怎么过滤某个分类
通过 GetList 可以获取自定义的文章列表,他可以通过分类、作者、时间、标签、搜索、置顶、随机等等手段自由组合出你要的文章列表。
过滤某个分类的代码如下(为了更加方便使用,我把实例做了下拆分处理)。
$w=array();
$w['count']=10;//显示数量
//分类id为1的文章不显示
$w['where_custom']=array();
$w['where_custom'][]=array('<>','log_CateID','1');
$result=GetList($w);
foreach($resultas$related){
echo'<ahref="'.$related->Url.'">'.$related->Title.'</a>';
}这里用到的where_custom是自定义where,当然他也可以用来设置其他的判断。
我们可以根据GetList参数配置,做更自由的调整。
array(
'count'=>10,//(可省略)
'cate'=>1,//(可省略)
'auth'=>2,//(可省略)
'date'=>'2020-1',//(可省略)
'tags'=>'abc',//(可省略)
'search'=>'s',//(可省略)
//以下是原$option参数的key键
'post_type'=>null,//指定查询Post表的类型(可省略)
'post_status'=>null,//指定查询Post表的状态(可省略)
'only_ontop'=>false,//指定全是置顶(可省略)
'only_not_ontop'=>false,//指定全不是置顶(可省略)
'has_subcate'=>false,//指定包含子孙目录(可省略)
'is_related'=>'文章id',//指定查询相关文章(可省略)
'order_by_metas'=>false,//指定按Metas值排序输出结果(可省略)
'random'=>5,//指定抽取5篇Post表的记录(可省略)
'where_custom'=>array(array('=','log_Template','')),//自定义where
'order_custom'=>array('log_ViewNums'=>'DESC','log_CommNums'=>'ASC'),//自定义order)


