Wordpress get_template_directory_uri가 하위 테마와 함께 작동하지 않습니다.
그래서 쓰고 있습니다.mr tailor
어린이를 주제로 해서요테마 폴더의 이름은 그에 따라 다음과 같습니다.mrtailor
그리고.mrtailor-child
.
그러나 대시보드의 테마 관리자에서는 다음과 같이 부릅니다.Mr. Tailor
그리고.Mr. Tailor Theme
. 이것만 언급했어요, 왜냐하면 보통은 이것이 추가되기 때문입니다.child
결국은 대신에theme
.
문제는 일부 기능을 무시하고 어린이 테마에 배치한다는 것입니다.대본이 잘 돌아가겠죠, 장담하건대.get_template_directory_uri()
부모 테마의 uri를 반환합니다.
다음은 오버라이드 기능 중 하나의 예입니다.
<div class="row">
<div class="large-10 text-center large-centered columns">
<div class="cart-empty-banner cart-wishlist-empty-banner">
<img id="cart-empty-img" alt="cart-empty-image" width="480" height="233" src="<?php echo get_template_directory_uri() . '/images/empty_cart_black.png'; ?>" data-interchange="[<?php echo get_template_directory_uri() . '/images/empty_cart_black.png'; ?>, (default)], [<?php echo get_template_directory_uri() . '/images/empty_cart_black_retina.png'; ?>, (retina)]">
</div>
<p class="cart-empty cart-wishlist-empty"><?php _e( 'Your cart is currently empty.', 'mr_tailor' ) ?></p>
<?php do_action( 'woocommerce_cart_is_empty' ); ?>
<p class="return-to-shop"><a class="wc-backward" href="<?php echo get_permalink( wc_get_page_id( 'shop' ) ); ?>"><?php _e( 'Return To Shop', 'mr_tailor' ) ?></a></p>
</div><!-- .large-10-->
</div><!-- .row-->
어떤 도움이나 안내라도 해주시면 감사하겠습니다.
테마의 템플릿 디렉토리를 검색하거나, 다시 말해 상위 테마를 검색합니다.
하위 테마의 경우 하위 테마에서 사용하는 스타일시트 디렉토리 경로를 검색하는 방법을 사용해야 합니다.
사용가능get_stylesheet_directory()
자식 테마에 파일을 포함하려면functions.php
파일. 여기 예가 있습니다.
include (get_stylesheet_directory() . '/myWidget/newsWidget.php');
where I have `newsWidget.php` file in myWidget folder which is in childtheme directory.
다음과 같은 중요한 차이점을 기억합니다.
get_stylesheet_directory()
그리고.get_stylesheet_directory_uri()
전자는 하위 테마 디렉토리로 리디렉션되고 후자는 하위 테마 디렉토리로 리디렉션됩니다.style.css
자식 테마의 파일입니다.
언급URL : https://stackoverflow.com/questions/24882389/wordpress-get-template-directory-uri-is-not-working-with-a-child-theme
'programing' 카테고리의 다른 글
보내기 전에 사용하고 $.post로 완료하시겠습니까? (0) | 2023.10.15 |
---|---|
libclntsh.so .12.1 : node-oracledb 샘플을 실행할 때 공유 개체 파일을 열 수 없음 (0) | 2023.10.15 |
요청 본문이 KOA에 정의되지 않았습니다. (0) | 2023.10.15 |
C/C++ 다차원 배열 초기화 시 크기 생략 (0) | 2023.10.15 |
부트스트랩 응답 페이지에서 디브의 중심을 맞추는 방법 (0) | 2023.10.10 |