是否可以覆盖默认值update_count_callback
对于类别?默认函数统计已发布的帖子,而我想统计私人帖子。我不想注册新的分类法。
如何覆盖类别的默认UPDATE_COUNT_CALLBACK
1 个回复
最合适的回答,由SO网友:Chris_O 整理而成
在update\\u count\\u回调函数中,检查$post->;post\\u状态,如果post\\u状态不是私有状态,则不增加计数。
看到这个了吗excellent answer 在编写自定义update\\u count\\u回调函数时。
编辑:
误读了问题。要覆盖类别分类法的现有默认值,可以创建一个覆盖全局$wp\\u taxonomies变量的函数function change_category_arg() {
global $wp_taxonomies;
if ( ! taxonomy_exists(\'category\') )
return false;
$new_arg = &$wp_taxonomies[\'category\']->update_count_callback;
$new_arg->update_count_callback = \'your_new_arg\';
}
add_action( \'init\', \'change_category_arg\' );
结束