typecho隐藏某个特定分类

2025-12-02 03:38:19

1、typecho现有的输出所有分类代码

$this->widget('Widget_Metas_Category_List')

2、网上查到的相关代码,其中ignore表示要隐藏的分类mid

$this->widget('Widget_Metas_Category_List','ignore=1')

3、但通过上面的代码无法实现隐藏功能,查看系统文件,最后在/var/Widget/Metas/Category/Edit.php中看到了下面这段代码

/** 父级分类 */

$options = array(0 => _t('不选择'));

$parents = $this->widget('Widget_Metas_Category_List@options',

(isset($this->request->mid) ? 'ignore=' . $this->request->mid : ''));

while ($parents->next()) {

$options[$parents->mid] = str_repeat('    ', $parents->levels) . $parents->name;

}

4、尝试把@options加进去,就可以实现隐藏typecho分类

最后代码

<?php $this->widget('Widget_Metas_Category_List@options','ignore=1')->to($categories); ?>

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢