第8回目のWordPressのサイト作り
前回の記事までの記事はこちらから
WordPress オリジナルテーマを作る〜ヘッダー〜
WordPress オリジナルテーマを作る〜ヘッダーその2〜
WordPress オリジナルテーマを作る〜メイン部分〜
WordPress オリジナルテーマを作る〜メイン部分その2〜
WordPress オリジナルテーマを作る〜サイドとフッター〜
WordPress オリジナルテーマを作る〜テーマに分割~
WordPress オリジナルテーマを作る〜記事一覧を取得~
記事の中身を作成する
今日はsingle.phpを作りました。
single.phpは投稿した記事を表示するページです。
ほとんどindex.phpと変わらないので、まずはindex.phpをコピーして複製します。
それからサムネイルに関する部分をまるっと削除して
the_excerpt();をthe_content();に変更すれば完了です。
<!-- index.php --> <?php get_header(); ?> <div class="container"> <div class="main"> <div class="post"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post-content"> <p class="ttl"><a href="<?php the_permalink(); ?>"></a><?php the_title(); ?></p> <div class="post-meta"> <ul> <li><i class="fa fa-clock-o" aria-hidden="true"></i><?php echo get_the_date_date(); ?></li> <li><i class="fa fa-folder-open-o" aria-hidden="true"></i><? php the_category(', '); ?></li> </ul> </div> <div class="post-txt"> <p><?php the_content(); ?></p> </div> </div> </div> <?php end while; else: ?> <p>記事はありません</p> <?php endif; ?> </div> <?php get_sidebar(); ?> </div> <?php get_footer(); ?>
今回使ったテンプレートタグは
the_content();
→本文全文を取得する
せば!