Upload
mignon-style
View
11.960
Download
3
Embed Size (px)
Citation preview
Mignon Style
Webデザイナー
WordPress公式ディレクトリ テーマ「Chocolat」
プラグイン「MS Custom Login」デベロッパー
WordPressスターターテーマ「_s」コントリビューター
http://mignonstyle.com/
@mignon_style
mignonxstyle
https://profiles.wordpress.org/mignonstyle
Adobe BracketsのWordPress用コードヒントも作ってます!
2013年7月 WordPressの勉強をはじめる
2014年5月 WordPress公式ディレクトリにテーマ「Chocolat」を登録
2014年6月 WordCamp Kansai 2014に遊びに行く
2014年8月 WordFes Nagoya 2014 登壇/実行委員
2014年10月 WordCamp Tokyo 2014 登壇
2014年10月 WordPress公式ディレクトリにプラグイン「MS Custom Login」を登録
2015年4月 BracketsにWordPress用コードヒントのアドオンを登録
2015年7月 WordCamp Kansai 2015 実行委員
2015年8月 WordFes Nagoya 2015 実行委員
2015年9月 _s のコントリビューターになる
2015年10月 WordCamp Tokyo 2015 登壇
2016年1月 WordBash Kyoto 登壇/運営
WordBashハングアウト放送中!!
1 フォルダの作成
子テーマ用のファイルをいれる
フォルダ(ディレクトリ)を作成します
(親テーマディレクトリ名)-childの
ような名前が推奨
一般的には子テーマ名の
小文字の半角英数字
空白は「-」に
置き換えます
2 style.cssの作成
style.cssの冒頭に テーマの詳細 を記述します
/*
Theme Name: Twenty Sixteen Child
Template: twentysixteen
*/
Theme Name: 子テーマのテーマ名
Template: 親テーマのディレクトリ名
3 スタイルシートの読込
親テーマのスタイルシートを読み込みます
/*
Theme Name: Twenty Sixteen Child
Template: twentysixteen
*/
@import url('../twentysixteen/style.css');
@importで親テーマの
スタイルシートを読み込み
3 スタイルシートの読込
今はコレ!!
functions.phpに親テーマの
スタイルシートを読み込むコードを記述
functions.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' );
}
コピペでOK!
親テーマのスタイルシートを読み込んだ後
子テーマのスタイルシートを自動的に読み込みます
functios.phpの始めに
PHPの「開始タグ」を記述
functions.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' );
}
親テーマのstyle.cssを追加
PHPの「終了タグ」は書かなくてもOK
子テーマのスタイルシートが読み込まれない場合
functions.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' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent-style' ) );
}
子テーマのスタイルシートが読み込まれない場合
functions.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' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( 'parent-style' ) );
}
親テーマのstyle.cssを追加
子テーマのstyle.cssを追加
2 FTPでアップロードする場合
子テーマのフォルダをWordPressをインストールしてる
サーバーのwp-content/themesにアップロード
wp-content /themes ディレクトリに入れます
親テーマがインストールされていないと子テーマが
エラーになるので親テーマを自分でインストール
zipファイルを解凍
フォルダ名をテーマのディレクトリ名に書き換えて
テーマフォルダへ
wp-content /themes ディレクトリに入れます
更新したテーマは削除して
1つ前のバージョンに置き換える
functions.php
子テーマで同名の関数を書き換えることができる
if ( ! function_exists( 'my_theme_posted_on' ) ) {
function my_theme_posted_on () {
}
}
! function_exists があるかチェック!!
特定のタイミングで関数を呼び出したり
書き換えたりできる
functions.php
function my_theme_posted_on () {
do_action( 'my_theme_posted_on_pre' );
return apply_filters( 'my_theme_posted_on_result', $result );
}
フィルタやフックがあるかチェック!!