0
votes

I want to create a child theme for twentyfifteen in Wordpress with more than one stylesheet files from the parent theme. The route is htdocs/wordpress-1/wp-content/themes/twentyfifteen-child so according to similar questions here the code of the child should be:

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' );

?>

The path for the parent content (for style sheets) is: htdocs/wordpress-1/wp-content/themes/twentyfifteen/css But still in the theme selection page there is no preview of the child theme and when loading the theme the are no css rules loaded from the parent theme (twentyfifteen). I cannot find the problem, if someone can help me..

1
there is a site for WordPress questions : wordpress.stackexchange.commmm

1 Answers

1
votes

Looks like you didn't enqueue the parent's css stylings. Try the following in your child theme's function.php file:

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' );