0

저는 html5blank 테마의 하위 테마를 설정하는 데 많은 어려움을 겪고 있습니다. 내가 부모 테마를 새로 설치하고 처음부터 시작하는 시점까지 - 그리고 내가이 글을 쓰면서이 글을 쓰자! 기본적으로 자녀를 만들면서 이제는 내 맞춤 /css/main.css 파일을로드해야합니다. 설정 과정에 대한 설명은 다음과 같습니다.html5blank에 대한 Wordpress 하위 테마

새로 다운로드 한 html5blank 폴더를/themes /에 놓고 활성화했습니다. 그 후 "/ html5blank-child"라는/themes/안에 다른 폴더를 만들었습니다. 그 안에 새로운 빈 style.css와 functions.php를 만들었습니다.

/* 
Theme Name: HTML5 Blank Child 
Theme URI: http://example.com/twenty-fifteen-child/ 
Description: HTML5 Blank Child Theme 
Author:  My Name 
Author URI: http://myportfolio.com 
Template:  html5blank 
Version:  1.0.0 
License:  GNU General Public License v2 or later 
License URI: http://www.gnu.org/licenses/gpl-2.0.html 
Tags:   light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready 
Text Domain: html5blank-child 
*/ 

그리고 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'); 
} 
?> 

있는 style.css내에서 나는 다음 있습니다. 모든 일을 마치면 모든 것이 여전히 작동하는 것처럼 보입니다. 나는 웹 사이트의 정적 템플릿을 만들었으므로 html5blank-child에 'img', 'css', 'font'및 'js'폴더를 드롭합니다.

지금 내 '실제'CSS 파일의 경로가 있습니다 html5blank 아이/CSS/main.css가를

나는이 파일을로드 할 필요가 내 functions.php CSS의 경로를 조정 들었다. to : /css/main.css ...하지만 파일을 전혀로드하지 않습니다. 나는 또한 get_template_directory_uri() 대신 get_stylesheet_directory_uri()을 사용하여 시도했지만 다른 사람이 알려 줬지만 행운은 없습니다.

내가 이와 같은 프로세스를 문서화 한 이유는 http://localhost:8888/websitename/admin을 사용하는 Wordpress 관리자에 액세스하면 지난 번에 정상적으로 수행되는 것처럼 wp-admin으로 리디렉션되지 않습니다. 또한 게시물을 저장할 때 빈 페이지가 나타납니다. 다행스럽게도 이번에는 좋지 않은 시작이긴하지만 지금은 내 파일을로드해야합니다.

누군가가 도와 줄 수 있기를 바랍니다. :)

답변

0

먼저 하위 테마의 style.css 안에 기본 테마의 style.css를 가져와야합니다.

먼저 @import를 사용하여 CSS 파일을 가져옵니다.

또한 자식 테마의 functions.php에서 부모 - 스타일을 제거하고 부모 테마있는 style.css 먼저 주어진 다음과 같이 당신의 html5blank 아이/CSS/main.css가,

add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles'); 
function my_theme_enqueue_styles() { 
    wp_enqueue_style('child-main', get_stylesheet_directory_uri() . '/css/main.css'); 
} 
+1

고마워요! 분명히 그것을하는 새로운 방법이 있고 @import를 더 이상 사용하지 않습니까? https://codex.wordpress.org/Child_Themes – user1406440

+0

예 그들은 그것을 표시하지 않았지만 두 가지 방법으로 사용할 수 있습니다. 1) @import 2) 부모/자식으로부터 style.css를 큐에 넣습니다. –

+0

"이전 방법은 @import를 사용하여 부모 테마 스타일 시트를 가져 오는 것이 었습니다. 스타일 시트를로드하는 데 걸리는 시간이 길어 지므로 더 이상 모범 사례가 아닙니다. functions.php에서 enqueue 메소드를 사용하는 것이 가장 좋습니다. – user1406440

0

로드를 포함한다 다음과 같이 자녀 테마 CSS를로드하십시오.

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'); 
    wp_enqueue_style('child-main', get_stylesheet_directory_uri() . '/css/main.css', array('parent-style')); 
}