我想在Wordpress中创建一个二十五个子主题,其中包含来自父主题的多个样式表文件。 路线是htdocs / wordpress-1 / wp-content / themes / twentyfifteen-child所以根据类似的问题,孩子的代码应该是:
的style.css:
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://localhost/wordpress-1/wp-content/themes/twentyfifteen-child/
Description: My first child theme, based on Twenty Fifteen
Author: Daniel Pataki
Author URI: http://danielpataki.com
Template: twentyfifteen
Version: 1.0.0
Tags: black, green, white, light, dark, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready, responsive-layout, infinite-scroll, post-slider, design, food, journal, magazine, news, photography, portfolio, clean, contemporary, dark, elegant, modern, professional, sophisticated
Text Domain: twenty-fifteen-child
*/
的functions.php:
<?php
function enqueue_parent_styles() {
wp_enqueue_style( 'twentyfifteen-editor-style', get_template_directory_uri().'css/editor-style.css',array(), null, 'all' );
wp_enqueue_style( 'twentyfifteen-ie', get_template_directory_uri().'css/ie.css',array(), null, 'all' );
wp_enqueue_style( 'twentyfifteen-ie7', get_template_directory_uri().'css/editor-ie7.css',array(), null, 'all' );
wp_enqueue_style( 'twentyfifteen-style', get_stylesheet_uri(), '', null, 'all' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
?>
父内容(对于样式表)的路径是: htdocs中/ WordPress的-1 /可湿性粉剂内容/主题/ twentyfifteen / CSS 但仍然在主题选择页面中没有子主题的预览,并且在加载主题时没有从父主题加载的css规则(二十五)。如果有人可以帮助我,我找不到问题..
答案 0 :(得分:0)
看起来你并没有将父母的css样式排队。在您的子主题的function.php文件中尝试以下内容:
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version') );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );