Xサーバーでsingle.phpが読み込まれない理由を教えてください
解決したいこと
xサーバーにWordPressの投稿を表示させたいです
public_html/wp/wp-content/themes/twentytwentythree/single.php
上記の階層に下記内容のsingle.phpを入れていますが
投稿を開くとURLは正しいのにpublic_html/index.php
のindex.phpの内容が表示されてしまいます
トップページでは下記内容のindex.phpを読み込み最新投稿が3つ表示されるようにはなっているので、WordPressの投稿を読み込めていない訳ではなさそうです。
しかし、投稿を表示しようとするとURLは正しく表示されていますが、index.phpの内容が表示されてしまい、single.phpが読み込めていません。
single.phpを読み込まない理由を教えていただきたいです。
single.php
<?php
get_header(); // ヘッダーを読み込み
?>
<main>
<section class="single-post">
<div class="container">
<?php
if (have_posts()) :
while (have_posts()) : the_post();
?>
<article>
<h1><?php the_title(); ?></h1>
<p class="post-date"><?php echo get_the_date('Y年n月j日'); ?></p>
<div class="post-thumbnail">
<?php
if (has_post_thumbnail()) {
the_post_thumbnail('large');
}
?>
</div>
<div class="post-content">
<?php the_content(); ?>
</div>
</article>
<?php
endwhile;
else :
echo '<p>投稿が見つかりません。</p>';
endif;
?>
</div>
</section>
</main>
<?php
get_footer(); // フッターを読み込み
?>
index.php
<section class="main-news">
<div class="main-news-container">
<h3 class="vartical news-ttl fadeUpTrigger fadeUp">お知らせ</h3>
<ul class="main-news-list fadeUp">
<?php
$recent_posts = new WP_Query([
'posts_per_page' => 3, // 投稿数を3に制限
'post_status' => 'publish',
]);
if ($recent_posts->have_posts()):
while ($recent_posts->have_posts()): $recent_posts->the_post();
?>
<li class="main-news-item">
<a href="<?php the_permalink(); ?>">
<!-- アイキャッチ画像 or デフォルト画像 -->
<div class="main-news-thumbnail">
<?php if (has_post_thumbnail()): ?>
<?php the_post_thumbnail('medium'); ?>
<?php else: ?>
<img src="sample.jpg" alt="サンプル画像">
<?php endif; ?>
</div>
<!-- タイトル -->
<h4 class="main-news-title"><?php the_title(); ?></h4>
<!-- 本文抜粋 -->
<p class="main-news-excerpt"><?php echo wp_trim_words(get_the_excerpt(), 100, '...'); ?></p>
</a>
</li>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
</ul>
<!-- 「お知らせ一覧はこちら」ボタン -->
<div class="main-news-button-container fadeUp">
<a href="https://www.matsukou.hyogo.jp/news" class="main-news-button">お知らせ一覧はこちら</a>
</div>
</div>
</section>
0