WordPress后台如何屏蔽特定分类选项?

作者:30115776@qq.com

WordPress程序功能很强大,有些用户咨询ordPress后台如何屏蔽特定分类选项?其实思路很简单,就是判断WordPress后台,然后根据条件过滤掉特定的分类。

add_filter(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’get_terms\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’filter_get_terms\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, $priority = 10, $accepted_args = 1);

function filter_get_terms($terms) {

if (!is_admin()) {

return $terms;

}

foreach ($terms as $key => $term) {

// 需要排除的category id

if ($term->term_id == 11) {

unset($terms[$key]);

}

}

return $terms;

}

发表评论