get_theme_mod()
get_theme_mod( string $name, string|false $default = fa…
get_theme_mod( string $name,  string|false $default = false )
检索当前主题的主题修改值。
Retrieve theme modification value for the current theme.
检索当前主题的主题修改值。
Retrieve theme modification value for the current theme.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
如果修改名不存在,那么$default将通过sprintf()PHP函数传递,模板目录URI作为第一个字符串,样式表目录URI作为第二个字符串。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 | 
|---|---|---|---|
| $name | (string) | 必需 | 主题修改名称。 | 
| $default | (string | false) | 可选 | 主题修改默认值。 | 
返回(Return)
(mixed)主题修改值。
源码(Source)
/**
 * Retrieve theme modification value for the current theme.
 *
 * If the modification name does not exist, then the $default will be passed
 * through {@link http://php.net/sprintf sprintf()} PHP function with the first
 * string the template directory URI and the second string the stylesheet
 * directory URI.
 *
 * @since 2.1.0
 *
 * @param string      $name    Theme modification name.
 * @param bool|string $default
 * @return string
 */
function get_theme_mod( $name, $default = false ) {
	$mods = get_theme_mods();
	if ( isset( $mods[$name] ) ) {
		/**
		 * Filter the theme modification, or 'theme_mod', value.
		 *
		 * The dynamic portion of the hook name, `$name`, refers to
		 * the key name of the modification array. For example,
		 * 'header_textcolor', 'header_image', and so on depending
		 * on the theme options.
		 *
		 * @since 2.2.0
		 *
		 * @param string $current_mod The value of the current theme modification.
		 */
		return apply_filters( "theme_mod_{$name}", $mods[$name] );
	}
	if ( is_string( $default ) )
		$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
	/** This filter is documented in wp-includes/theme.php */
	return apply_filters( "theme_mod_{$name}", $default );
}| 更新版本 | 源码位置 | 使用 | 被使用 | 
|---|---|---|---|
| 2.1.0 | wp-includes/theme.php:921 | 23 | 5 | 
笔记(Notes)
调用自定义背景色
使用默认值调用背景色
类别:WordPress 函数手册、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!