岡山・広島の広告パートナー ヤマト広告ブログリレー

岡山・広島エリアで広告の制作・コンサルティングを提供するヤマト広告のブログリレー。

ヤマト広告ブログリレー
岡山・広島を中心に活動する広告制作・広告パートナー。
デザインやホームページ制作、折込チラシやテレビCMなど販促物や媒体出稿、
リスティング広告などSEMやSEOなどWebマーケティング全般。

Wordpress Child-テーマの作成

こんにちは !!
アラム です!!
お久しぶりです!!

When you update wordpress active theme, the previous theme folder is replaced with the updated folder and you lose all your changes. But it's also important to update the active theme because it may have security update. Today I want to discuss how to make a child theme to solve this problem.

The Child theme contains:
1. style.css (which will have your modified/added css)
2. function.php (which will have your modified/added codes in function.php)
3. Other custom folders like img(if any)
4. template files that you changed/modified like header.php/footer.php/template_header etc.

the first two files (style.css and function.php) are must!

Let's start!!

FIRST OF ALL TAKE A BACKUP OF YOUR THEME FOLDER !!

Step 1.

Create new folder under wp-content --> themes and name it like yourActiveThemesName-child. For example, if your theme is twentyfifteen then the child's name will be, twentyfifteen-child.
So your wp-content --> themes folder will contain, wp-content-->>themes-->> twentyfifteen, twentyfifteen-child

Step 2:

Create style.css under twentyfifteen-child folder. and write the following to your style.css file.
/***
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 ***/

Notes This code snippet is only for if you are using Twenty Fifteen theme. Please replace the theme name and other things according to your active theme's style.css top.
now please copy all your custom modified/added classes to this style.css file.

Step 3:

Create functions.php under the twentyfifteen-child folder. We need to en-queue the parent and child theme stylesheets.
write the following code to this function.php file.

f:id:yamato-alam:20170605142533p:plain

Notes you need to replace the 'parent-style' with your theme's name carefully.

If you have more than one css file, repeat following line
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/YOUR_STYLESHEET_NAME.css' );
line with your css file.

Step 4:

If you have some custom folders or other modified template files then copy them to your child folder.

Step 5:

Now you are all set. Go to your Dashboard-> Appearence-> Themes
you will see your child theme is there. Activate your child them.

Now you are ready to update your theme. Updating the theme will no longer change your modifications.

For more info:
Child Themes « WordPress Codex

Thats all for today !!

さようなら !!
またね!!

ページトップ