Wordpressの新着の記事の情報をトップページなどに載せる方法
RSSでやる方法もあるけど、同サーバーにあるので以下の方法で出来た。
<?php require_once($_SERVER['DOCUMENT_ROOT'] ."/wp/wp-blog-header.php");?> <?php $posts = get_posts('numberposts=3&order=desc'); foreach($posts as $post): ?> <dl class="clearfix"> <dt><?php echo date("Y年m月d日", strtotime($post->post_date)); ?></dt> <dd><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dd> </dl> <?php endforeach; ?>
wp-blog-header.phpのパスとかCSSとかは好みで。
参考:
トピック: 自作トップページのindex.phpに新着5件表示 | WordPress.org
query_posts で指定できるパラメーター // understandard
Google AJAX Feed APIを使って、静的ページに外部ブログのRSSを取得・表示させるやつを私も試してみた – マイペースクリエイターの覚え書き