get_theme_mod()获取主题的自定义信息

目录

描述

译文

为当前主题检索主题修改值。

若修改名称不存在, sprintf() 会将$default、模板目录URI的第一个字符串以及样式表单目录URI的第二个字符串一并传递。

原文

Retrieves a modification setting for the current theme. Along with set_theme_mod() this function can sometimes offer theme developers a simpler alternative to the Settings API when there is a need to handle basic theme-specific settings.

If the modification name does not exist, then the $default will be passed through sprintf() with the first string the template directory URI and the second string the stylesheet directory URI.

get_theme_mod() 描述

用法

<?php get_theme_mod$name$default ); ?>

get_theme_mod() 用法

参数

$name

(string) (必填) Theme modification name.

默认值: None

$default

(boolean|string) (可选)

默认值: false

get_theme_mod() 参数

返回值

(string) 

get_theme_mod() 返回值

示例

Calling the Custom Background Color

This example could be used to add the custom background color as a border on the top of the footer. It would be css inserted in the header:

get_theme_mod() 示例

注意

get_theme_mod() 注意

历史

添加于 版本: 2.1.0

get_theme_mod() 历史

源文件

get_theme_mod() 函数的代码位于 wp-includes/theme.php.

get_theme_mod() 源文件

相关