我试图通过管理面板添加使用自定义背景的功能 . 我使用了WP codex中给出的here示例 . 我正在使用WordPress 3.5.2
我正在获取后台选项,这一切似乎都能正常工作,直到我实际查看页面 . 我注意到它添加了一个内部样式,它指的是一个类名为“custom-background”的主体,但是主体的实际类是“customize-support” . 当我使用Chrome的调试调整它们时,它应用了正确的样式,所以它是某个Wordpress函数中的错误吗?我试图找到它给身体那个课但却找不到任何东西的地方 .
functions.php from theme
<?php
/*
* Adds the custom header option to the theme
*/
function addthemeoptions(){
//Default values of the header image
$header_defaults = array(
'default-image' => '%s/images/header.png',
'random-default' => false,
'flex-height' => false,
'flex-width' => false,
'default-text-color' => '',
'header-text' => false,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
//Adds the support to use custom header images
add_theme_support( 'custom-header', $header_defaults );
$background_defaults = array(
'default-color' => '#000000',
'default-image' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $background_defaults );
}
//Execute our custom theme functionality
add_action( 'after_setup_theme', 'addthemeoptions' );
?>
generated style in head
<style type="text/css" id="custom-background-css">
body.custom-background { background-color: #0a0a0a; }
</style>
body tag from debug
<body class=" customize-support" style>
提前致谢
Edit: I 've found a temporary fix to just add the correct class value into my header.php where body tag is opened but I feel there should be a more complete solution as I' m难以纠正应该由WordPress中的函数正确生成的内容吗?
1 回答
您的身体标签 header.php 应该看起来:
<body <?php body_class(''); ?>>