typecho隐藏某个特定分类

时间:2026-02-16 03:39:25

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); ?>

© 2026 途途旅游
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com