首页 建站教程 Zblog建站 正文

zblog首页不显示/过滤指定分类的文章

实现方法:通过函数过滤指定分类,重建分页后,挂接Filter_Plugin_ViewList_Core接口。接口位置:zb_system/function/c_system_event.php,有兴趣可自行研究。教程代码:1、在主题的include.php文件最后一行的?>上面添加以下函数代码:function exclude_category(&am...

实现方法:

通过函数过滤指定分类,重建分页后,挂接Filter_Plugin_ViewList_Core接口。

接口位置:zb_system/function/c_system_event.php,有兴趣可自行研究。

教程代码:

1、在主题的include.php文件最后一行的?>上面添加以下函数代码:

function 主题ID_filter_category(&$type,&$page,&$category,&$author,&$datetime,&$tag,&$w,&$pagebar){
	global $zbp;	
	if($type == 'index'){
		$w[]=array('<>','log_CateID',1);
		//以下是为了重建分页,过滤了分类,数量会发生变化
		$pagebar = new Pagebar($zbp->option['ZC_INDEX_REGEX']);
		$pagebar->PageCount = $zbp->displaycount;
		$pagebar->PageNow = $page;
		$pagebar->PageBarCount = $zbp->pagebarcount;
	}	}

以上代码第四行中的1是要过滤的分类ID,分类ID请在后台分类管理中查看。


2、在主题激活时执行的函数中(一般是ActivePlugin_主题ID(){})添加以下代码:

Add_Filter_Plugin('Filter_Plugin_ViewList_Core','主题ID_filter_category');

保存后即可生效。

希望对有此需求的用户有所帮助。

打赏
海报

本文由优美主题原创或收集发布

转载请注明本文地址:https://www.umtheme.com/zblog/111.html

相关推荐

发布评论

ainiaobaibaibaibaobaobeishangbishibizuichiguachijingchongjingdahaqiandaliandangaodw_dogedw_erhadw_miaodw_tuzidw_xiongmaodw_zhutouganbeigeiliguiguolaiguzhanghahahahashoushihaixiuhanheixianhenghorse2huaixiaohuatonghuaxinhufenjiayoujiyankeaikeliankouzhaokukuloukunkuxiaolandelinileimuliwulxhainiolxhlikelxhqiuguanzhulxhtouxiaolxhwahahalxhzanningwennonuokpinganqianqiaoqinqinquantouruoshayanshengbingshiwangshuaishuijiaosikaostar0star2star3taikaixintanshoutianpingtouxiaotuwabiweifengweiquweiwuweixiaowenhaowoshouwuxiangjixianhuaxiaoerbuyuxiaokuxiaoxinxinxinxinsuixixixuyeyinxianyinyueyouhenghengyuebingyueliangyunzanzhajizhongguozanzhoumazhuakuangzuohenghengzuoyi
感谢您的支持