add_theme_support() 用于在我们的当前使用的主题添加一些特殊的功能,函数一般写在主题的functions.php文件中,当然也可以再插件中使用钩子来调用该函数,如果是挂在钩子上,那他必须挂在after_setup_theme钩子上,因为 init hook 对于一些功能来说,已经太迟了.
(在后台外观->主题_>点击自定义)

先看效果截图:

用法
<?php add_theme_support($feature);?>
$feature:字符串(必填)。将要添加的功能名称。
$args,…:混合(可选)。额外参数用以指定具体功能。
参数说明
$feature
(string) (必须) 需要添加特殊功能名称,可以是以下参数:
◆‘post-thumbnails’—– 增加缩略图支持
◆‘automatic-feed-links’—–自动输出RSS
◆‘post-formats’—– 增加文章格式功能
◆‘custom-background’—– 增加自定义背景
◆‘custom-header’—– 增加自定义顶部图像
◆‘menus’——自定义导航菜单
目前支持的功能参数主要有:
post-thumbnails:特色图片。
post-formats:文章形式。
html5:HTML5支持。
custom-logo:自定义网站Logo图标。
custom-header-uploads:顶部图像上传。
custom-header:自定义网站顶部内容。
custom-background:自定义网站背景内容。
title-tag:自动生成页面标题信息,需调用<?php wp_head();?>。
customize-selective-refresh-widgets:小部件选择性更新。
starter-content:内容初始化。
responsive-embeds:自适应嵌入内容。
align-wide:配置块编辑器宽对齐。
dark-editor-style:配置暗风格块编辑器。
disable-custom-colors:禁用快编辑器自定义颜色。
disable-custom-font-sizes:禁用快编辑器自定义字体大小。
editor-color-pallete:配置块编辑器调色板。
editor-font-sizes:配置块编辑器字体大小。
editor-styles:配置块编辑器样式。
wp-block-styles:启用默认块编辑器样式。
默认: None
该函数定义在 wp-includes/theme.php 文件中,具体代码如下:
$args:
数组,功能相关的额外参数。
也就是说你可以如下使用:(该函数必须在主题的 functions.php 文件中调用)
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');
add_theme_support('post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'));
add_theme_support(
'custom-background',
array(
'default