【发布时间】:2017-03-14 18:36:27
【问题描述】:
我知道人们也遇到过类似的问题,但通读 stackoverflow 和 WP Codex 上的问题并没有帮助我解决这个问题。 这是我制作的第二个儿童主题。第一个工作完美。出于某种原因,即使我所做的一切都是一样的,但这并不能反映父主题的格式。我的怀疑是我要么需要为这个特定主题排队多个 .css,要么我有一个不正确的标签。 希望新的眼睛能发现问题。
这是子主题的 style.css:
/*
Theme Name: Kale-child
Theme URI: https://panaceats.com/
Author: ****
Author URI: https://panaceats.com/
Description: child theme of Kale
Template: kale
Version: 1.0.0
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.en.html
Text Domain: kale
Domain Path: /languages/
Tags: one-column, two-columns, three-columns, right-sidebar, grid-layout, flexible-header, custom-background, custom-colors, custom-header, custom-menu, featured-images,footer-widgets, full-width-template, theme-options, threaded-comments, translation-ready, food-and-drink
*/
这是子主题的functions.php:
<?php
function my_theme_enqueue_styles() {
$parent_style = 'kale-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' );
?>
如您所见,我已按照WP Codex - CT 的指示进行操作。
This 是格式应该是什么样子。
更新:我现在通过将父 style.css 中的所有内容复制/粘贴到子主题,使子主题看起来像父主题。但是,这不是违背了入队的目的吗?如果我正确地将父母和孩子排队,父母的格式不应该反映在孩子主题中吗?
【问题讨论】:
-
在 header.php 中从头部添加样式,不要使用这个愚蠢的函数
-
“kale-style”是否与 Kale 主题在调用 style.css 时在其 functions.php 中使用的句柄相同?
标签: php css wordpress parent-child