钩子文档

default_category_post_types

💡 云策文档标注

概述

default_category_post_types 是一个 WordPress 过滤器,用于指定除 'post' 外需要默认分类的文章类型。它允许开发者自定义哪些文章类型必须设置默认分类。

关键要点

  • 过滤器名称:default_category_post_types
  • 参数:$post_types,一个字符串数组,表示文章类型名称,默认为空数组
  • 用途:扩展默认分类应用到其他自定义文章类型
  • 相关函数:wp_set_post_categories() 用于设置文章分类
  • 引入版本:WordPress 5.5.0

代码示例

$default_category_post_types = apply_filters( 'default_category_post_types', array() );

📄 原文内容

Filters post types (in addition to ‘post’) that require a default category.

Parameters

$post_typesstring[]
An array of post type names. Default empty array.

Source

$default_category_post_types = apply_filters( 'default_category_post_types', array() );

Changelog

Version Description
5.5.0 Introduced.