创建子主题时出现问题

时间:2017-07-29 23:27:06

标签: wordpress themes

我试图在wordpress中创建一个子主题,但我得到了这个错误

  

破碎的主题

     

安装了以下主题但不完整。

     

名称说明
  Rife child模板丢失了。独立主题需要有一个index.php模板文件。子主题需要在style.css样式表中有一个Template头。

我做错了什么?

这是文件
的style.css

/*
Theme Name: Rife child
Description: Made by <a href="http://apollo13themes.com/" target="_blank">Apollo13</a>.<br/> Get support from <a href="http://support.apollo13.eu/" target="_blank">Forum</a>.
Author: Apollo13
Author URI: https://apollo13themes.com/
Theme URI: https://apollo13themes.com/themes
License: GNU General Public License version 3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Tags: theme-options, post-formats, two-columns, translation-ready
Text Domain: rife
Version: 1.0
*/

Functions.php

<?php

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() .     '/style.css' );

}
?>

1 个答案:

答案 0 :(得分:0)

实际上,子主题只需要两个文件: style.css 和functions.php。

我认为您的 style.css 缺少标题。以下是儿童主题的强制标题示例。

/*
 Theme Name: My Child Theme
 Theme URI: https://www.example.com/themes
 Description: My Child Theme
 Author: John Deo
 Author URI: https://www.example.com/
 Template: parent_theme_name
 Version: 1.0
 Text Domain: my-child-theme
*/

此外,您需要通过将其包含在您的子主题 function.php 中来排队父样式表:

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
?>