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_body_class() - 检索body元素的类名数组 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / get_body_class()

get_body_class( string|string[] $class = '' )

检索body元素的类名数组


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 "af4e913ce2975e7e84605084283fd620" 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 "e6b1d6133777aaa42d065ffd9d1f9396" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

body

class


参数

$class

(string|string[])(可选) 要添加到类列表的以空格分隔的类名字符串或数组。

默认值: ''


返回

(string[]) 类名数组。



源码

查看源码 官方文档


更新日志

版本描述
2.8.0开始引入

使用示例

  • 示例1
    // If has "home" class in the body
    if (in_array('home', get_body_class())) {
        // Class is present
    } else {
        // Class is not present
    }