投稿記事の日付を表示する<?php the_date(); ?>
WordPressで投稿記事の日付を表示するテンプレートタグが
<?php the_date(); ?>
です。
ループ内で使用します。
記事の日付とタイトルを表示したいときは、以下のように記述します。
<?php if(have_posts()):while(have_posts()):the_post(); ?>
<p>
<?php the_date(); ?>
<?php the_title(); ?>
</p>
<?php endwhile;endif; ?>
このテンプレートタグはパラメータ挿入ができます。
<?php the_date(’①’,'②’,'③’,④); ?>
①表示形式の文字列
デフォルトはWordPress設定による②日付の前に挿入する文字列
③日付の後に挿入する文字列
④出力形式
TRUE ・・・ 標準形式(デフォルト)
FALSE ・・・ PHP形式
たとえば、太字で「2007年11月30日(金)」のように表示したいときは以下のように記述します。
<?php if(have_posts()):while(have_posts()):the_post(); ?>
<?php the_date('Y年m月d日(D)','<strong>,'</strong>'); ?>
<?php endwhile;endif; ?>
-スポンサーサイト-
トラックバック URL :

コメントはございません。