0
A
回答
0
你只需要按照以下3個步驟:
1)在/可溼性粉劑內容的主題創建一個文件夾/主題/:
「建議(雖然不是必需的,尤其是如果你正在創建一個供公衆使用的主題),你的子主題目錄的名稱會附加'-child'。「。
這裏創建的每個文件都會覆蓋父主題中的文件。例如,您可以創建新的頁面模板:https://developer.wordpress.org/themes/template-files-section/page-template-files/或覆蓋現有的模板。
2)創建是一個style.css的文件,並開始它:
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfifteen
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: twenty-fifteen-child
*/
這裏添加您的自定義樣式。更多信息:https://codex.wordpress.org/Theme_Development#Theme_Stylesheet
3)創建的functions.php
在這個文件中,你可以添加新的功能,你的孩子的主題或修改現有的。
您還需要在這裏入隊您的父主題的CSS和JS,以及您在子主題上創建的新CSS和JS。類似的東西會做大部分的時間:
<?php
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')
);
}
add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');
?>
現在,您可以添加自定義的簡(https://codex.wordpress.org/Shortcode_API),窗口小部件區域(https://codex.wordpress.org/Widgetizing_Themes)等。
更多的文檔關於兒童主題:https://codex.wordpress.org/Child_Themes
相關問題
- 1. WordPress的兒童主題覆蓋父母的主題包括
- 2. WordPress兒童主題
- 3. WordPress的/兒童主題 - 加載父母的選項
- 4. removeView()對兒童的父母
- 5. WordPress的兒童主題風格過了父母的主題風格
- 6. WordPress的兒童主題
- 7. WordPress的兒童主題include_once
- 8. WordPress的兒童主題&enqueue_script
- 9. WordPress的functions.php兒童主題
- 10. WordPress中的兒童主題也有自己的兒童主題
- 11. wordpress兒童主題functions.php
- 12. wordpress兒童主題多個兒童主題wp_enqueue_scripts
- 13. WordPress主題圖片兒童主題
- 14. WordPress的:處理兒童和父母主題之間的CSS優先
- 15. WordPress的 - 從父主題主題選項是缺少兒童主題
- 16. Wordpress兒童主題CSS問題
- 17. Flexboxs兒童溢出父母
- 18. 父母兒童微調器
- 19. WordPress的兒童主題style.css不工作
- 20. WordPress的兒童主題css優先
- 21. WordPress的兒童主題如何工作?
- 22. WordPress的兒童主題CSS路徑
- 23. WordPress的兒童主題CSS入隊
- 24. WordPress的兒童主題 - 一般瞭解
- 25. WordPress的兒童主題:覆蓋功能
- 26. 多個WordPress的兒童主題
- 27. WordPress的:編輯兒童主題
- 28. WordPress的兒童主題路徑
- 29. WordPress的兒童主題和頁腳
- 30. 兒童主題文件無法覆蓋到父主題文件
你可能會更好地服務於https://wordpress.stackexchange.com/ –
看看這裏:https://codex.wordpress.org/Child_Themes – mmm