Wordpress 하위 테마 스타일.css가 작동하지 않습니다.
부모 테마와 같은 형식으로 파일 구조를 작성했습니다.부모님의 테마는 알파인이라고 불리며 알파인 안에는 기능이 있습니다.php 및 style.css 파일.추가 style.css 파일은 없는 것 같습니다.
Alpine-child라는 디렉토리를 만들고 그 안에 함수를 만들었습니다.php 및 style.css 파일.
자녀 스타일에 대한 변경이 구현되지 않은 이유를 알 수 없지만 부모 스타일에 동일한 변경을 가했을 때 구현됩니다.css
이것이 내 아이 스타일입니다.css:
/*
Theme Name: Alpine Child
Theme URI: http://www.creative-ispiration.com/wp/alpine/
Description: My first child theme, based on Alpine
Author: MilkshakeThemes
Author URI: http://themeforest.net/user/milkshakethemes
Template: Alpine
Version: 1.0.0
Tags: one-column, two-columns, right-sidebar, fluid-layout, custom-menu, editor-style, featured-images, post-formats, rtl$
Text Domain: alpine-child
*/
이건 내 아이 기능이야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' );
}
?>
이 사진을 보세요.<head>태그. 더 중요한 것은 스타일시트의 순서를 보는 것입니다.
하위 테마의 스타일이 먼저 추가된 다음 상위 테마의 모든 스타일이 추가됩니다.그러면 상위 테마의 스타일이 하위 테마 스타일을 재정의합니다.
priority를 변경할 수 있습니다.my_theme_enqueue_stylesadd_action의 세 번째 파라미터를 사용하여 부모 뒤에 실행되는 함수입니다.그러면 자녀 테마 스타일이 마지막으로 큐잉되고 CSS가 예상대로 작동할 수 있습니다.
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', 11 );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'child-style', get_stylesheet_uri() );
}
?>
이 방법은 효과가 있었습니다.
<?php
function my_theme_enqueue_styles() {
$parent_style = 'twentyseventeen-style';
$child_style = 'twentyseventeen-child-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( $child_style, get_stylesheet_uri() );
}
?>
다른 답변은 하나도 없었어요
Divi 4.4.1에서 Divi 4.10.8로 업데이트한 후 Child 테마 부모 CSS가 작동하지 않았습니다.웹 사이트를 조사했더니 Divi style.css 파일이 헤더 정보만 있는 빈 파일(업데이트 후)과 CSS를 표시하기 위해 필요한 코드가 다른 파일(style-static.min.css)에 있는 것을 알게 되었습니다.자체 테마 함수에서 파일 이름을 변경했습니다.php 파일을 style.css에서 style-static.min.css로 전송합니다.이것으로 문제가 해결되어 CSS가 기능하고 있습니다.
사용한 코드 아래를 참조하십시오.
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 11);
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style-static.min.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
}
하위 테마를 큐에 넣어야 합니다.style.css그 때문에, 기능은 다음과 같습니다.
function my_theme_enqueue_styles() {
$parent_style = 'parent-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' );
이 문서를 참조하십시오.
Craig Hick의 답변은 나에게 효과가 있었고 Wordpress 문서의 기본 코드가 작동하지 않은 이유도 알게 되었다.
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'parent-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')
); }
이 경우 wp_get_theme()->get('Version') 행이 상위 테마와 동일한 버전 번호인 1.0.0을 반환했습니다.그래서 아이테마 css 버전 번호를 1.0.1로 변경했는데 작동했어요.
내 아이 테마는 현재 다음과 같은 코드를 가지고 있습니다.
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
//load child theme custom CSS
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles', 11 );
function my_theme_enqueue_styles() {
wp_enqueue_style( 'child-style', get_stylesheet_uri() );
}
?>
제가 요.//load child theme custom CSSCSS를 사용하다위에 @jrod가 제시한 코드를 추가했더니 동작했습니다.저는 제 아이 테마 코드가 완성되었는지, 그리고 다른 어떤 것도 추가할 필요가 없다는 것을 여러분들에게 확인해야 합니다.자테마 JS 파일에 있는 커스텀 JS 파일도 가져올 수 있을지 모르겠습니다.
<?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' );
}
?>
child them style의 코멘트에서 버전을 삭제해 주세요.css는 wordpress 6.1에서 동작합니다.
언급URL : https://stackoverflow.com/questions/39975520/wordpress-child-theme-style-css-not-working
'programing' 카테고리의 다른 글
| get_module이 모든 투고를 반환하지 않음 (0) | 2023.03.16 |
|---|---|
| Wordpress 데이터베이스 스키마가 외부 키를 사용하지 않는 이유는 무엇입니까? (0) | 2023.03.16 |
| 특정 투고 유형에 대해 Gutenberg/블록 에디터를 비활성화하는 방법 (0) | 2023.03.16 |
| 단일 페이지 애플리케이션(ARIA 등)에서의 접근성 (0) | 2023.03.16 |
| IDE를 사용하여 스프링 부트 메인 실행 (0) | 2023.03.16 |