Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
get_theme_mod() - 检索已启用主题的主题修改值 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / get_theme_mod()

get_theme_mod( string $name, mixed $default = false )

检索已启用主题的主题修改值


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "d2f01662425b41068c74bdc173040b69" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "3a41fd57de8104db46dad2693d7f2deb" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

mod

theme 主题more...


描述

如果修改名称不存在并且$default是一个字符串,那么默认值将通过 sprintf()PHP函数传递,模板目录URI作为第一个值,样式表目录URI作为第二个值。


参数

$name

(string) (必填) 主题修改名称

$default

(mixed) (可选) 主题修改默认值

默认值: false


返回

(mixed) 主题修改值。



源码

查看源码 官方文档


更新日志

版本描述
2.1.0开始引入

使用示例

  • 示例1

    调用自定义背景色
    此示例可用于在页脚顶部添加自定义背景色作为边框。它将以css插入到header中:

    .footer {
         border-top: solid 1px #<?php echo get_theme_mod( 'background_color' ); ?>;
    }
    
    
  • 示例2

    用默认值调用背景色
    有时您需要设置默认值以避免任何不良情况。此示例可用于添加自定义背景色作为页脚顶部的边框,默认颜色为白色。它将以css插入到header中:

    .footer {
         border-top: solid 1px #<?php echo get_theme_mod( 'background_color', '#fff' ); ?>;
    }
  • 示例3

    必须用适当的转义get_theme_mod。

    .search-bar {
    	background-color: <?php echo esc_html( get_theme_mod( 'talash_background_color', '#000' ) ); ?>;
    }
    
    
    <a href="<?php echo esc_url( get_theme_mod( 'talash_url' ) ); ?>">