我經歷了一個教程,創建在以下鏈接在WordPress的模塊化的CSS:functions.php文件無法過濾父主題
http://themeshaper.com/2009/04/30/modular-css-wordpress-child-themes/
當我使用的style.css從導入CSS文件它的工作原理。 這裏是在style.css中的代碼在子主題:
的style.css
/* CSS Document */
/*
Theme Name: Chiron
Description: Child theme of thematic
Template: thematic
*/
/* Using @import, we can borrow style sheets from the Parent Theme */
/* Reset the browser defaults */
@import url('../thematic/library/styles/reset.css');
/* Apply default typography */
@import url('../thematic/library/styles/typography.css');
/* Add WordPress image styles */
@import url('../thematic/library/styles/images.css');
/* Add a basic layout */
@import url('../thematic/library/layouts/2c-l-fixed.css');
/* Start with some default styles */
@import url('../thematic/library/styles/18px.css');
但是當我刪除所有來自style.css的進口和使用的functions.php我的孩子裏面主題目錄來加載它不工作的CSS文件。
的functions.php
<?php
function childtheme_create_stylesheet() {
$templatedir = get_bloginfo('template_directory');
$stylesheetdir = get_bloginfo('stylesheet_directory');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $templatedir ?>/library/styles/reset.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $templatedir ?>/library/styles/typography.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $templatedir ?>/library/styles/images.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $templatedir ?>/library/layouts/2c-l-fixed.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $templatedir ?>/library/styles/18px.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $stylesheetdir ?>/style.css" />
<?php
}
add_filter('thematic_create_stylesheet', 'childtheme_create_stylesheet');
?>
任何一個可以請建議我在哪裏做錯了嗎?
在遵循極老的教程時要小心,在發佈堆棧溢出問題之前,請不要忘記Google解決您的問題。該教程已超過6年,並且[Google的第一個結果爲'thematic_create_stylesheet'](https://www.google.com.au/#q=thematic_create_stylesheet)解釋說,在Thematic 1.0中刪除了該鉤子(超過三幾年前),而應該使用'wp_enqueue_style'。 –