เมื่อแก้ไขธีม WordPress วิธีนี้จะช่วยให้ใช้งานไฟล์ที่สำรองไว้ (เรียกว่าธีมลูก) โดยไม่แตะต้องธีมต้นฉบับ
- เพื่อให้ตรวจสอบธีมลูกที่ใช้งานได้ง่าย ให้สร้างโฟลเดอร์ใหม่ในโฟลเดอร์ “wp-content/themes” โดยนำชื่อธีมมาประกอบกัน (เช่น หากธีมต้นฉบับชื่อ “twentyfifteen” ให้สร้างโฟลเดอร์ชื่อ “twentyfifteen-child”)
- คัดลอก “style.css” ของธีมต้นฉบับไปยังโฟลเดอร์ธีมลูก แล้วแก้ไข “Theme Name” และ “Themplate” ดังตัวอย่างด้านล่าง
[php]/*
Theme Name: Twenty Fifteen Child
Theme URI: https://wordpress.org/themes/twentyfifteen/
Template: twentyfifteen
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen’s simple, straightforward typography is readable on a wide variety of screen sizes, and suitable for multiple languages. We designed it using a mobile-first approach, meaning your content takes center-stage, regardless of whether your visitors arrive by smartphone, tablet, laptop, or desktop computer.
Version: 1.5
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, blue, gray, pink, purple, white, yellow, dark, light, two-columns, left-sidebar, fixed-layout, responsive-layout, accessibility-ready, custom-background, custom-colors, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, threaded-comments, translation-ready
Text Domain: twentyfifteenTemplate: twntyfifteen
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you’ve learned with others.
*/
[/php] - สร้างไฟล์ “functions.php” ในโฟลเดอร์ธีมลูกโดยใช้โค้ดด้านล่าง
[php]
<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
}
?>
[/php] - คัดลอก “screenshot.png” ของธีมต้นฉบับไปยังโฟลเดอร์ธีมลูก
- คัดลอกไฟล์ของธีมต้นฉบับที่ต้องการแก้ไขไปยังโฟลเดอร์ธีมลูก จากนั้นแก้ไขและนำไปใช้งานได้
(อ้างอิง : http://codex.wordpress.org/Child_Themes)





