WordPressテーマ制作-ステップ16-page.php作成

投稿日:

固定ページの編集をします。ファイル名はpage.phpとなります。 前ステップで作成したsingle.phpをコピーしてもとを作成します。

<div id="contents">
 <h2><?php the_title(); ?></h2>
 <?php if ( have_posts()): ?>
 <ul>
 <?php while ( have_posts() ) : the_post(); ?>
 <li>
 <p class="meta">
 <span>日付:<a href="<?php the_permalink(); ?>"><time datetime="<?php the_time('y-m-d'); ?>"><?php the_time( get_option('date_format') ); ?></a></span>
 </p>
 <p>
 <?php the_content(); ?>
 </p>
 <p class="meta">
 <span>カテゴリー:<a href="<?php the_permalink(); ?>"><?php the_category(','); ?></a></span>
 <span><?php the_tags(); ?></span>
 </p>
 </li>
 <?php endwhile; ?>
 </ul>
 <?php endif; ?>
 <div class="single_navi">
 <?php wp_link_pages(); ?>
 <p>
 <span class="single_navi_pre">
 <?php previous_post_link(); ?>
 </span>
 <span class="single_navi_next">
 <?php next_post_link(); ?>
 </span>
 </p>
 </div>
 <div class="comm">
 <?php comments_template(); ?>
 </div>
 </div>

いらない部分を削除します。

<p >
  <span>日付:
    <a href=”<?php the_permalink(); ?>”>
    <time datetime=”<?php the_time(‘y-m-d’); ?>”>
    <?php the_time( get_option(‘date_format’) ); ?>
    </a>
  </span>
</p>
<p >
  <span>カテゴリー:<a href=”<?php the_permalink(); ?>”><?php the_category(‘,’); ?></a></span>
  <span><a href=”<?php the_permalink(); ?>”><?php the_tags(); ?></a></span>
</p>
<div >
  <?php comments_template(); ?>
</div>

以上です。ソースはこんな感じ

<div id="contents">
 <h2><?php wp_title(''); ?></h2>
 <?php if ( have_posts()): ?>
 <ul>
 <?php while ( have_posts() ) : the_post(); ?>
 <li>
 <p>
 <?php the_content(); ?>
 </p>
 </li>
 <?php endwhile; ?>
 </ul>
 <?php endif; ?>
 <div class="single_navi">
 <?php wp_link_pages(); ?>
 <p>
 <span class="single_navi_pre">
 <?php previous_post_link(); ?>
 </span>
 <span class="single_navi_next">
 <?php next_post_link(); ?>
 </span>
 </p>
 </div>
 </div>

カテゴリー:WordPress,テーマ タグ: , , , , ,

WordPressテーマ制作-ステップ16-page.php作成に1件のコメント

  • szkoła wyższa より:

    Nie mogło być lepiej. Świetnie. Pozdrawiam

  • szkoła wyższa へ返信する コメントをキャンセル

    メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

    Translate »