TwentyFifteenを独自テンプレートにカスタマイズする方法
シンプルなWordPressのテンプレートを探していたところ、意外と「TwentyFifteen」が良さそうだったのでカスタマイズしてみました。
0. ファイル構成
TwentyFourteenに比べるとファイルも少なくなっているので良いですね。
ちゃんと見てないですが、style.css内のメディアクエリもブレークポイントが少なくなっているようでカスタマイズしやすそうです。
content*.phpといったファイルは、WordPressループなどを含むコンテンツの表示用のファイル。
また、inc/以下のファイルはfunctions.phpで読み込まれるカスタマイズ用のファイルです。
404.php | 404 テンプレート |
archive.php | アーカイブ |
author-bio.php | 著者情報 |
comments.php | コメント |
content-link.php | リンクポストフォーマット用 |
content-none.php | コンテンツがない時用 |
content-page.php | 固定ページ用 |
content-search.php | 検索結果 |
content.php | メインとなるコンテンツ表示 |
footer.php | フッター |
functions.php | テーマのための関数 |
header.php | ヘッダー |
image.php | 画像添付テンプレート |
inc/back-compat.php | WordPress4.1未満用 |
inc/custom-header.php | カスタムヘッダー用 |
inc/customizer.php | テーマカスタマイザー |
inc/template-tags.php | テンプレートタグ |
index.php | メインインデックスのテンプレート |
page.php | 固定ページテンプレート |
search.php | 検索結果 |
sidebar.php | サイドバー |
single.php | 単一記事の投稿 |
style.css | スタイルシート |
rtl.css | RTL スタイルシート |
2. functions.phpから不要なコードを消す
WordPress4.1未満用の互換性確保のために back-compat.php を読み込む部分。 今回は不要なので削除。
/**
* Twenty Fifteen only works in WordPress 4.1 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.1-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
twentyfifteen_setup()内の不要な設定を削除。
言語ファイルの設定。一部英語化してしまうけれど、あとで修正するので削除。
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on twentyfifteen, use a find and replace
* to change 'twentyfifteen' to the name of your theme in all the template files
*/
load_theme_textdomain( 'twentyfifteen', get_template_directory() . '/languages' );
ポストフォーマットの登録。使わない人は削除。
/*
* Enable support for Post Formats.
*
* See: https://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
) );
テーマを管理画面からカスタマイズする用(カスタムヘッダーなど)不要なので削除。
$color_scheme = twentyfifteen_get_color_scheme();
$default_color = trim( $color_scheme[0], '#' );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'twentyfifteen_custom_background_args', array(
'default-color' => $default_color,
'default-attachment' => 'fixed',
) ) );
custom-header.php、customizer.phpは不要なので削除。
/**
* Implement the Custom Header feature.
*
* @since Twenty Fifteen 1.0
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Customizer additions.
*
* @since Twenty Fifteen 1.0
*/
require get_template_directory() . '/inc/customizer.php';
3. 不要なファイルを消す
functions.phpを編集した後に、下記のファイルを削除。
rtl.css
back-compat.php
custom-header.php
customizer.php
content-link.php
4. カスタマイズ
To be Updated…
[amazonjs asin=“B00UR988KS” locale=“JP” title=“本格ビジネスサイトを作りながら学ぶ WordPressの教科書 Ver.4.x対応版”]