記事をランダムで表示する。
201004/28 Category : WEB Tag : php, Wordpress
ブログをある程度の期間運営していると、どうしても古い記事は見てもらえない事が多いはず。そこでwordpressの便利タグ queryを使って、記事をランダムで表示するコードをメモ。
<?php if (have_posts()) : query_posts('showposts=3&orderby=rand'); while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php endwhile; wp_reset_query(); endif; ?>