我创建了一个新的style.css并在子主题中使用它。我在wp内容中创建了一个新文件夹,并将其命名为,并上传我创建的style.css。现在,我转到wp仪表板->外观->主题,并查看我创建的子主题。我发现了这个错误:
Broken Themes
The following themes are installed but incomplete. Themes must have a stylesheet and a template.
Name Description
Accesspress Lite The parent theme is missing. Please install the "AccesspressLite" parent theme.以下是css子主题格式:
/*
Theme Name: Accesspress Lite
Theme URI: http://access-keys.com/accesspresslite/
Description: Accesspress Lite Child Theme
Author: Yang
Author URI: http://www.example.com
Template: accesspress-lite
Version: 2
Tags: blue, white, light, custom-menu, one-column, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, fluid-layout, custom-background, featured-image-header, sticky-post, theme-options, threaded-comments, featured-images, full-width-template, custom-header, flexible-header, responsive-layout
Text Domain: accesspress-lite-child
*/
@import url("../accesspress-lite/style.css");发布于 2016-04-13 15:28:09
您需要的所有信息都可以在这里找到:https://codex.wordpress.org/Child_主题
启动和运行它的重要部分是:
确保父主题存在(在您的情况下,完整的可访问性主题)
为您的子主题创建唯一的文件夹名。
在子主题文件夹中创建一个style.css文件。
/*
Theme Name: Your Child Theme Name
Theme URI: http://access-keys.com/accesspresslite/
Description: Accesspress Lite Child Theme
Author: Your Name
Author URI: http://www.your-child-theme.com
Template: accesspress-lite
Version: 1.0
Tags: blue, white, light, custom-menu, one-column, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, fluid-layout, custom-background, featured-image-header, sticky-post, theme-options, threaded-comments, featured-images, full-width-template, custom-header, flexible-header, responsive-layout
Text Domain: accesspress-lite-child
*/确保模板行与父文件夹匹配。
在子主题文件夹中创建一个functions.php文件。在该文件中,导入父主题样式。这样做,而不是样式表中的@import,可以确保满足依赖关系。
function child_theme_enqueue_styles() {
wp_enqueue_style( 'parent-styles', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-styles',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent-styles' )
);
}
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles' );注意,作为子主题,任何时候使用get_template_directory_uri()都是在抓取父主题目录。使用get_stylesheet_directory_uri()将为您提供子主题目录。
发布于 2014-06-20 04:00:55
添加名称-子style.css:
/*
Theme Name: Your Theme
Version: 1.0
Author: Your Author
*/上传到主机
https://wordpress.stackexchange.com/questions/150188
复制相似问题