百度 | 神马 | 搜狗 | 技术文档 | 学习资料分享 - 记录帝国CMS及运维技术的点点滴滴
你的位置:首页 > 实用IT技术 » 正文

【Wordpress相关】WordPress 常用函数 / add_theme_support

发布时间:2020-09-17

WordPress 常用函数 / add_theme_support,

简介

允许主题去支持特定的主题功能。

这个函数必须在主题的 functions.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

Top