函数原型
add_theme_support( string $feature, mixed $args ): void|false
函数描述
Registers theme support for a given feature.
是否弃用
未弃用
函数参数
-
$feature
string
Required - The feature being added. Likely core values include:
'admin-bar''align-wide''automatic-feed-links''core-block-patterns''custom-background''custom-header''custom-line-height''custom-logo''customize-selective-refresh-widgets''custom-spacing''custom-units''dark-editor-style''disable-custom-colors''disable-custom-font-sizes''editor-color-palette''editor-gradient-presets''editor-font-sizes''editor-styles''featured-content''html5''menus''post-formats''post-thumbnails''responsive-embeds''starter-content''title-tag''wp-block-styles''widgets''widgets-block-editor'
-
$args
mixed
Optional - extra arguments to pass along with certain features.
函数返回值
void|false Void on success, false on failure.
函数位置
File: wp-includes/theme.php.
函数源码
add_theme_support( 'title-tag' );
add_theme_support( 'custom-logo', array(
'height' => 480,
'width' => 720,
) );源码链接
变更日志
| Version | Description |
|---|---|
| 6.0.0 | The html5 feature warns if no array is passed as the second parameter. |
| 5.8.0 | The widgets-block-editor feature enables the Widgets block editor. |
| 5.6.0 | The post-formats feature warns if no array is passed as the second parameter. |
| 5.5.0 | The custom-logo feature now also accepts 'unlink-homepage-logo'. |
| 5.3.0 | Formalized the existing and already documented ...$args parameter by adding it to the function signature. |
| 5.0.0 | The responsive-embeds, align-wide, dark-editor-style, disable-custom-colors, disable-custom-font-sizes, editor-color-palette, editor-font-sizes, editor-styles, and wp-block-styles features were added. |
| 4.7.0 | The starter-content feature was added. |
| 4.5.0 | The customize-selective-refresh-widgets feature was added. |
| 4.1.0 | The title-tag feature was added. |
| 3.9.0 | The html5 feature now also accepts 'gallery' and 'caption'. |
| 3.6.1 | The html5 feature requires an array of types to be passed. Defaults to 'comment-list', 'comment-form', 'search-form' for backward compatibility. |
| 3.6.0 | The html5 feature was added. |
| 3.4.0 | The custom-header-uploads feature was deprecated. |
| 2.9.0 | Introduced. |

