is_date() – WordPress テンプレートタグのリファレンス
全ての日付ベースのアーカイブページが表示されている場合です。(例. 月、年、日、時間ベースのアーカイブ)
When any date-based archive page is being displayed (i.e. a monthly, yearly, daily or time-based archive).
日付ベースの違い
誰かが日付順のサイトを参照するならば、異なる色を使用して別の年に投稿を区別してみましょう:
If someone browses our site by date, let’s distinguish posts in different years by using different colors:
<?php
// this starts The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
<?php
// are we showing a date-based archive?
if (is_date())
{
if (date('Y') != get_the_date('Y'))
{
// this post was written in a previous year
// so let's style the content using the "oldentry" class
echo '<div class="oldentry">';
} else {
echo '<div class="entry">';
}
} else {
echo '<div class="entry">';
}
the_content('Read the rest of this entry »');
?>
</div>
Tags:WordPress テンプレートタグ パーマリンクタグ リファレンス 条件タグ
HOME » WordPressの条件タグ » is_date()
Page 1 of 0
ツイート
ブログ更新: is_date() – http://tinyurl.com/y72pw93
ブログ更新: is_date() – WordPress*リファレンス – http://tinyurl.com/y72pw93