简体   繁体   中英

Wordpress - child theme won't complete installation

I'm using a child theme with HTML5 Blank as the parent theme. I've used this before without any issue but for some reason I'm now getting the following error on my themes page -

Broken Themes The following themes are installed but incomplete. Name Description
HTML5 Blank Child Theme The parent theme is missing. Please install the "html5blank" parent theme.

This is what I have in my folder -

style.css

/*
 Theme Name:   HTML5 Blank Child Theme
 Description:  A child theme of the HTML5 Blank WordPress theme
 Author:       Mike Whitehead
 Template:     html5blank
 Version:      1.0.0
*/

I've tried numerous different variations on this - also copying the official wordpress guide. The above wording worked for me on my last project so don't know why it won't work now.

This is my functions file -

functions.php

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'html5blank-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

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

Not sure why this isn't working. Any assistance would be appreciated.

The child themes style.css 'Template' tag should match that of the parent themes folder name eg.

/*
 Theme Name:   HTML5 Blank Child Theme
 Description:  A child theme of the HTML5 Blank WordPress theme
 Author:       Mike Whitehead
 Template:     html5blank-stable
 Version:      1.0.0
*/

As per the WordPress Codex page on Child Themes - https://codex.wordpress.org/Child_Themes

"The Template line corresponds to the directory name of the parent theme. The parent theme in our example is the Twenty Fifteen theme, so the Template will be twentyfifteen. You may be working with a different theme, so adjust accordingly."

Get Your Parent Theme's Textdomain and put it as child theme's Template name. Let's say your Parent theme's Style.css header like this...

/*
 Theme Name:   HTML5 Parent Theme
 Description:  A HTML5 Blank Parent WordPress theme
 Author:       Mike Whitehead
 Text domain: html5blank
 Version:      1.0.0
*/

Then you can use this Text domain name into your child theme like this..

/*
 Theme Name:   HTML5 Blank Child Theme
 Description:  A child theme of the HTML5 Blank WordPress theme
 Author:       Mike Whitehead
 Template:     html5blank
 Version:      1.0.0
*/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM