2013年09月12日 追記・変更

再度、今回やる事の確認
HTMLのみで作成されたHTMLファイルの静的サイトをWordPressに移行する作業を行う。移行するにあたり、WordPressの新テーマとして作成する必要があるので、オリジナルテーマ作成の勉強を行っている。
今回はブログタイプのhtmlファイルをWordPressにする方法を解説する。
オリジナルテーマはstyle.cssとindex.phpが最低限あれば動く
まずは、テーマ用のstyle.cssとindex.phpの2つのファイルを準備する事から始める。WordPressは、テーマディレクトリ内にテーマ宣言されたstyle.cssとindex.phpが存在すると、テーマとして認識する。

新テーマ用のフォルダをwordpressの「themes」ディレクトリ内に作成
新テーマ用のディテクトリ名は「test」とした。先ほどダウンロードしたフォルダの中にある「images」フォルダと「index.html」「style.css」を新テーマ用の「test」ディレクトリ内に移動する。

index.htmlをindex.phpに拡張子を変更する
現在のindex.htmlをindex.phpへと拡張子を変更する。変更することで、ファイルがサーバー上でphpとして認識される。

style.cssを編集する
style.cssの始めに以下を書く事で、WordPressがテーマとして認識する。/* Theme Name:自分のテーマ名 Theme URI:テーマのホームサイトのURL Description:テーマの説明 Author:作者である自分の名前 Author URI:作者である自分のサイトのURL Version:バージョン(任意) Tags:タグ(任意) */下記のようになる。style.css
/* Theme Name:test Theme URI:http://localhost/wordpress/ Description:テストで作ったオリジナルテーマ Author:佐藤 雅俊 Author URI:https://www.wordpressmatome.com/ Version:1 Tags:オリジナルテーマ */ @charset "UTF-8"; html { overflow-y:scroll; } body { margin:0; padding:0; line-height:1.6; letter-spacing:1px; font-family:Verdana, Helvetica, sans-serif; font-size:13px; color:#333; background:#ffffff; } br { letter-spacing:normal; } a { color:#333; text-decoration:none; } a:hover { color:#DF8713; text-decoration:none; } img { border:0; } h1,h2,h3,h4,h5,h6 { margin:0; } /* ページレイアウト */ #wrapper { width:789px; margin:0 auto; border-left:1px solid #ccc; border-right:1px solid #ccc; background:#fff; } #header { width:785px; margin:0 2px; background:#161a2c; } #menu { margin:0 2px; } #contents { clear:both; width:785px; margin:0 2px; padding:10px 0; } #main { float:left; width:560px; padding:0 5px; } #sidebar { float:right; width:200px; padding-right:5px; } #footer { clear:both; width:774px; margin:0 2px; } /* 回り込み解除 */ #contents:after { content:""; display:block; height:0; clear:both; visibility:hidden; } /* ヘッダー詳細 */ #header h1 { margin:0; padding:0 10px; font-size:24px; color:#fff; line-height:80px; } #header h1 a { color:#fff; } #header h1 a:hover { color:#DF8713; } /* メニュー詳細 */ #menu ul { margin:0 -1px 0 0; padding:0; list-style:none; } #menu li { float:left; margin-right:1px; background:#3f4878; } #menu li a{ display:block; width:130px; color:#fff; text-align:center; line-height:2.5; background:#3f4878; } #menu li a:hover{ color:#fff; background:#DF8713; } /* 回り込み解除 */ #menu ul:after{ content:""; display:block; height:0; clear:both; visibility:hidden; } /* メイン詳細 */ #main a { color:#00264d; } #main a:hover { border:0; color:#0f5539; border-bottom:1px solid #DF8713; } #main h2 { margin-bottom:3px; padding:2px 2px 2px 5px; font-size:15px; font-weight:bold; border-left:5px solid #4E3333; background:url(./images/bg_h2.gif); } #main h3 { margin-bottom:2px; padding-left:25px; font-size:15px; background:url("./images/cube01-003.gif") 0 50% no-repeat; } #main h4 { margin:0 0 5px 0; font-size:15px; } #main h5 { margin:0 0 5px 0; padding:2px; font-size:13px; color:#fff; background:#9C6565; } #main h6 { margin:0 0 5px 0; font-size:13px; color:#4E3333; border-bottom:2px solid #4E3333; } #main p{ margin:0 0 1em 0; } #main dl { margin:0; padding:0; } #main dt { font-weight:bold; } #main dd { margin:0 0 1em 0; padding:0; } #main ul, #main ol { margin:0 0 1em 40px; padding:0; } /* サイドバー詳細 */ #sidebar .section { margin-bottom:10px; padding:10px; background:#DEDDD0; } #sidebar h2 { padding-bottom:5px; text-align:center; font-size:15px; font-weight:bold; color:#fff; border-bottom:1px solid #93847B; } #sidebar ul { margin:0; padding:5px 0 0 10px; } #sidebar li { margin:0; padding-left:12px; background:#DEDDD0 url("./images/arrow37-002.gif") 0 50% no-repeat; list-style:none; } /* フッター詳細 */ .copyright { padding:20px 0; text-align:center; font-style:normal; font-size:11px; color:#333; border-top:1px solid #ccc; } /* 記事のメタ情報部分 */ .meta{ padding-bottom:10px; border-bottom:1px solid #ccc; }また、テーマのディレクトリに画像ファイル「screenshot.png」を入れておくと、管理画面においてテーマのキャプチャ画像が表示される。
画像サイズは横300px×縦225pxで作ると丁度良くなる。
管理画面にテーマのキャプチャ画像が表示された

テーマファイルは、必ずthemesディレクトリの中に置く
例)xamppの場合http://localhost/wordpress/wp-content/themes/テーマディレクトリ名上記のように、テーマファイルを置く。オリジナルテーマも同様。
今回はテーマファイルを全て「test」というディレクトリ名にまとめたので、下記のようになった。
http://localhost/wordpress/wp-content/themes/test

現在の「test」ディレクトリ内のファイルは下記のようになっている。
