トップページの作り方2
トップページに更新情報をリスト表示したい場合
<ul>
<?php
$myposts = get_posts('numberposts=10');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>&nbsp;<?php the_time('n/j') ?></li>
<?php endforeach; ?>
</ul>
カテゴリーを指定したい場合は
<ul>
<?php
$myposts = get_posts('numberposts=10&category=5');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>&nbsp;<?php the_time('n/j') ?></li>
<?php endforeach; ?>
</ul>
更新情報をサムネイル一覧で表示したい場合は、プラグイン Image Link を使用し、抜粋欄にサムネイルを貼り付け、
<?php
$myposts = get_posts('numberposts=10');
foreach($myposts as $post) :
?>
<?php the_excerpt(); ?>
<?php endforeach; ?>
最新記事を1つ表示し、その下にそれ以外をサムネイル一覧で表示したい場合は、~get_posts(‘numberposts=10&offset=1′); とする。
*excerpt はpタグでくくられるので、リストタグなどを使いたい場合はCustom Field GUI Utility のようなプラグインを利用します。
Trackback URL:
