WordPressのテーマ作成時にstyle.cssに記述するテーマ情報について

WordPressのテーマファイルのstyle.cssには、コメントでテーマの詳細を記述する必要があります。
テーマの新規作成時に記述することがたびたびあるので、コメントで記述する際の内容など改めて調べたことをメモ。

記述方法

まずstyle.cssに記述しなかった場合ですが、外観 > テーマ で以下のような表示になります。
custom_themesはテーマディレクトリ名です。

次に、デフォルトのテーマで用意されているTwenty Twenty-Oneのstyle.cssを見てみます。
テーマ詳細は以下のように記述されていました。

/*
Theme Name: Twenty Twenty-One
Theme URI: https://wordpress.org/themes/twentytwentyone/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Twenty-One is a blank canvas for your ideas and it makes the block editor your best brush. With new block patterns, which allow you to create a beautiful layout in a matter of seconds, this theme’s soft colors and eye-catching — yet timeless — design will let your work shine. Take it for a spin! See how Twenty Twenty-One elevates your portfolio, business website, or personal blog.
Requires at least: 5.3
Tested up to: 5.6
Requires PHP: 5.6
Version: 1.2
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwentyone
Tags: one-column, accessibility-ready, custom-colors, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, block-patterns, rtl-language-support, sticky-post, threaded-comments, translation-ready

Twenty Twenty-One WordPress Theme, (C) 2020 WordPress.org
Twenty Twenty-One is distributed under the terms of the GNU GPL.
*/

外観 > テーマ で以下のような表示になります。

色々な内容が書かれていますが、最低限Theme NameとAuthor、Description、Versionあたりがあれば問題なさそうです。
以下を追加して表示を試してみます。

/*
Theme Name: テーマ名
Author: cly7796.net
Description: テーマの説明文です。
Version: 1.0
*/

以下のように各項目が変更されました。

基本的にクライアント向けにテーマを作成する場合などはこの4項目くらいの記述があれば問題なさそうですが、テーマを配布したい場合はLicenseやTagsなども記述した方が良さそうです。

参考サイト

このエントリーをはてなブックマークに追加

関連記事

コメントを残す

メールアドレスが公開されることはありません。
* が付いている欄は必須項目です

CAPTCHA


コメントが承認されるまで時間がかかります。

2024年3月
 12
3456789
10111213141516
17181920212223
24252627282930
31