【WordPress相关】WordPress 常用函数 / add_theme_support
作品分类:Wordpress相关 支持 函数 功能 函数 常用 WordPress add_theme_support
WordPress 常用函数 / add_theme_support,
简介
允许主题去支持特定的主题功能。
这个函数必须在主题的 functiоns.php 文件中去调用,如果想通过 hook 调用,则必须使用 after_setup_theme 这个 hook,因为 init hook 对于一些功能来说,已经太迟了。
用法
<?php add_theme_support( $feature ); ?>
参数
$feature
(string) (required) 要添加的主题功能的名称。
目前主题支持的功能列表:
<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
- ‘post-formats’
- ‘post-thumbnails’
- ‘custom-background’
- ‘custom-header’
- ‘automatic-feed-links’
- ‘menus’
Default: None
返回值
无
修改记录
- 3.4: 开始支持 ‘custom-background’ 并废弃函数 add_custom_background().
- 3.4: 开始支持 ‘custom-header’ 并废弃函数 add_custom_image_header().
- 3.1: 开始支持 ‘post-formats’.
- 3.0: 开始支持 ‘automatic-feed-links’ 并废弃函数 automatic_feed_links().
- 2.9: 引入,并支持第一个功能:’post-thumbnails’
源文件
wp-includes/theme.php
原创文章,作者:starterknow,如若转载,请注明出处:https://www.starterknow.com/32058.html