我正在尝试在 wordpress 之外的静态页面上获取最新的 wordpress 帖子。我正在尝试以下代码,但它不起作用(即我没有得到任何输出)。
<?php
$config_file = $_SERVER['DOCUMENT_ROOT'].'/wp/wp-config.php';
include($config_file);
$postlist = get_posts('numberposts=5');
foreach ($postlist as $post) : ?>
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<?php endforeach; ?>