wp-moshimoプラグインは、添付テーマ以外でもカスタマイズで対応できます。
WordPress標準のテーマファイル「Twenty Seventeen」を使った場合のカスタマイズ方法を解説します。
《手順1》「twentyseventeen」の子テーマを作成する。
・自分で「twentyseventeen-child」というフォルダを作成する。
・「functions.php」というファイルを作成し、以下のソースコードを記述する。
1 2 3 4 5 6 |
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_parent_theme_file_uri() . '/style.css' ); } ?> |
・「style.css」というファイルを作成し、以下のコードを記述する。
1 2 3 4 5 |
/* Theme Name: twentyseventeen-child Template: twentyseventeen Theme URI: https://wordpress.org/themes/twentyseventeen/ */ |
《手順2》親フォルダ「twentyseventeen」の「page.php」ファイルを子テーマ「twentyseventeen-child」フォルダにコピーして、ファイル名を「page-list.php」に変更。
・24行目あたり〜36行目あたりの以下のコード部分を削除。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php while ( have_posts() ) : the_post(); get_template_part( 'template-parts/page/content', 'page' ); // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; endwhile; // End of the loop. ?> |
・削除した部分に、以下のコードをコピペ。
1 |
<?php include( 'wp-content/plugins/wp-moshimo/templates/moshimo-list.php' ) ?> |
↓ 以下の動画を参考にしてください。
《手順3》プラグイン → もしもAPIの設定 で、「Bootstrap4 Grid Systemを読み込む」にチェックする。
※以上のカスタマイズを行えば、「twentyseventeen」でも作成できますが、デザインをかなり調整しないと見栄えが良くないかもしれません。
他のテーマで構築する際の参考にしてみてください。