静的なHTMLテーマをWordPressテーマへ移行(WP化)するめも
カスタム投稿やカスタムフィールド、問い合わせフォーム、ページネーション、固定ページ、など実装パーツを揃える。
実装手順メモ(最小だとこの構成)
- index.html を分割:header.php / footer.php / index.php。HTMLの head 部分は header.php に移す。
- style と script は functions.php で enqueue(wp_enqueue_style / wp_enqueue_script)する。
- index.php に基本ループ(if : while : the_post(); … endwhile; endif;)を追加。
- テーマサポート(title-tag, post-thumbnails 等)やメニュー登録を functions.php に追加。
(以下はfunctions.php の抜粋)
PHP
<?php
add_action('wp_enqueue_scripts', function(){
wp_enqueue_style('theme-style', get_template_directory_uri().'/css/style.css', [], '1.0');
wp_enqueue_script('theme-highlight', get_template_directory_uri().'/js/highlight.pack.js', [], '1.0', true);
});
add_theme_support('title-tag');
add_theme_support('post-thumbnails');
チェックリスト
- header/footer に分割済み
- CSS/JS は enqueue で読み込まれている
- index.php に WordPress ループがある
- index.html を実際に分割して動作確認する。管理画面で投稿作成 → フロントで表示されるかをチェック。

コメント