Must be called in the theme's functions.php file to work. If attached to a hook, it must be after_setup_theme. The init hook may be too late for some features.
This code should be inserted into the theme's functions.php file.
// Register theme features
add_action( 'after_setup_theme', function(){
// the ability to change the background from the admin panel
add_theme_support( 'custom-background' );
// the ability to change the images in the header from the admin panel
add_theme_support( 'custom-header' );
// enable the menu in the admin panel
add_theme_support( 'menus' );
// create a meta tag <title> via hook
add_theme_support( 'title-tag' );
// possibility to load a logo image in the admin panel
add_theme_support( 'custom-logo', [
'height' => 190,
'width' => 190,
'flex-width' => false,
'flex-height' => false,
'header-text' => '',
] );
}
Notes
Global. Array. $_wp_theme_features
Changelog
Since 2.9.0
Introduced.
Since 3.4.0
The custom-header-uploads feature was deprecated.
Since 3.6.0
The html5 feature was added.
Since 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.
Since 3.9.0
The html5 feature now also accepts 'gallery' and 'caption'.
Since 4.1.0
The title-tag feature was added.
Since 4.5.0
The customize-selective-refresh-widgets feature was added.
Since 4.7.0
The starter-content feature was added.
Since 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.
Since 5.3.0
The html5 feature now also accepts 'script' and 'style'.
Since 5.3.0
Formalized the existing and already documented ...$args parameter by adding it to the function signature.
Since 5.4.0
The disable-custom-gradients feature limits to default gradients or gradients added through editor-gradient-presets theme support.
Since 5.5.0
The core-block-patterns feature was added and is enabled by default.
Since 5.5.0
The custom-logo feature now also accepts 'unlink-homepage-logo'.
Since 5.6.0
The post-formats feature warns if no array is passed as the second parameter.
Since 5.8.0
The widgets-block-editor feature enables the Widgets block editor.
Since 5.8.0
The block-templates feature indicates whether a theme uses block-based templates.
Since 6.0.0
The html5 feature warns if no array is passed as the second parameter.
Since 6.1.0
The block-template-parts feature allows to edit any reusable template part from site editor.
Since 6.1.0
The disable-layout-styles feature disables the default layout styles.
Since 6.3.0
The link-color feature allows to enable the link color setting.
Since 6.3.0
The border feature allows themes without theme.json to add border styles to blocks.
Since 6.5.0
The appearance-tools feature enables a few design tools for blocks, see WP_Theme_JSON::APPEARANCE_TOOLS_OPT_INS for a complete list.
Since 6.6.0
The editor-spacing-sizes feature was added.
add_theme_support() add theme support code WP 6.7.1