WordPress(ブロックエディタ)で自作した投稿ページ(home.php / single.php)固定ページ(page.php)を反映させたい

実現したいこと

  • WordPress(ブロックエディタ)で自作した投稿ページ(home.php / single.php)固定ページ(page.php)を反映させたい

前提

以下の構造で自作テーマを作った

style.css screenshot.jpg footer.php front-page.php function.php header.php home.php page.php single.php archive-work.php single-work.php

発生している問題・エラーメッセージ

  • テーマ > 外観 > エディタ > テンプレートにある「ホーム」「固定ページ」が反映されてしまう
  • front-page.phpだけは反映されている
  • Custom Post Type UIで作成したカスタム投稿だけは反映されている

自作したhome.phpのソースコード

<?php get_header(); ?> <section class="p-mv"> <div class="l-article"> <h1>News</h1> </div> </section> <section class="p-news"> <div class="l-article"> <ul class="p-news__ul"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <li> <div class="p-news__list"> <div class="p-news__list__text"> <p class="p-news__list__text__date"><?php echo get_the_date(); ?></p> <p class="p-news__list__text__link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> </div> </div> </li> <?php endwhile; else : ?> <p>該当の記事はありません。</p> <?php endif; ?> </ul> </div> </section> <section class="p-contact"> <div class="l-article"> <div class="p-contact__text"> <div> <h2 class="p-contact__text__title"><span>Contact</span>お問い合わせ</h2> <p>ご不明な点はお気軽にお問い合わせください</p> </div> <div class="p-contact__btn"> <a href="contact.html">お見積り・お問い合わせ</a> </div> </div> </div> </section> <?php get_footer();

テンプレート「ホーム」のソースコード

<!-- wp:template-part {"slug":"header-small-dark","theme":"unrealize","tagName":"header"} /--> <!-- wp:query {"queryId":0,"query":{"perPage":10,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true},"tagName":"main","displayLayout":{"type":"list"},"layout":{"inherit":true}} --> <main class="wp-block-query"><!-- wp:post-template {"align":"wide"} --> <!-- wp:group {"layout":{"inherit":true,"type":"constrained"}} --> <div class="wp-block-group"><!-- wp:post-title {"isLink":true,"align":"wide","fontSize":"var(\u002d\u002dwp\u002d\u002dcustom\u002d\u002dtypography\u002d\u002dfont-size\u002d\u002dhuge, clamp(2.25rem, 4vw, 2.75rem))"} /--> <!-- wp:post-featured-image {"isLink":true,"align":"wide","style":{"spacing":{"margin":{"top":"calc(1.75 * var(\u002d\u002dwp\u002d\u002dstyle\u002d\u002dblock-gap))"}}}} /--> <!-- wp:columns {"align":"wide"} --> <div class="wp-block-columns alignwide"><!-- wp:column {"width":"650px"} --> <div class="wp-block-column" style="flex-basis:650px"><!-- wp:post-excerpt /--> <!-- wp:post-date {"format":"F j, Y","isLink":true,"style":{"typography":{"fontStyle":"italic","fontWeight":"400"}},"fontSize":"small"} /--></div> <!-- /wp:column --> <!-- wp:column {"width":""} --> <div class="wp-block-column"></div> <!-- /wp:column --></div> <!-- /wp:columns --> <!-- wp:spacer {"height":"112px"} --> <div style="height:112px" aria-hidden="true" class="wp-block-spacer"></div> <!-- /wp:spacer --></div> <!-- /wp:group --> <!-- /wp:post-template --> <!-- wp:query-pagination {"paginationArrow":"arrow","align":"wide","layout":{"type":"flex","justifyContent":"space-between"}} --> <!-- wp:query-pagination-previous {"fontSize":"small"} /--> <!-- wp:query-pagination-numbers /--> <!-- wp:query-pagination-next {"fontSize":"small"} /--> <!-- /wp:query-pagination --></main> <!-- /wp:query --> <!-- wp:template-part {"slug":"footer","theme":"unrealize","tagName":"footer"} /-->

試したこと

  • テンプレートにそのまま自作したphpのソースを入れてみましたがだめでした

補足情報(FW/ツールのバージョンなど)

  • 親テーマ:twentytwentytwo
  • 以下のツールでテスト環境を作っています

https://localwp.com/

コメントを投稿

0 コメント