WordPressの記事一覧を外部プログラムから取り込む方法

wp-load.phpを読み込むとWordPressの関数を使えるのでこれを読み込むこと。

http://mypacecreator.net/blog/archives/983

<?php
require_once('foo/wordpress/wp-load.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="style.css" type="text/css" />
<title>wordpressの記事一覧を外部プログラムから取り込む方法</title>
</head>
<body>
<div id="container">
<div id="header">
        <h1>wordpressの記事一覧を外部プログラムから取り込む方法</h1>
</div>
<div id="main">
        <p>カテゴリを指定する場合は&quot;cat=N&quot;を指定する。</p>
        <ul>
<?php
$myposts = get_posts('numberposts=5&orderby=post_date');
foreach($myposts as $post) :
        // the_content()や、the_ID()を使用する場合は setup_postdata()が必要
        // @see http://wpdocs.sourceforge.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/get_posts
        setup_postdata($post);
?>
        <li><?php echo date("Y年m月d日", strtotime($post->post_date)); ?>
        :&nbsp;<a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
        </ul>
</div>
<div id="footer">
        <address>on PHP <?php print phpversion(); ?>.</address>
</div>
</div>
</body>
</html>