如何在自定义PHP文件中包含Wordpress帖子?

Joe*_*nsn 4 php wordpress rss blogs

这就是我想要做的:

我想/summary.php在我的博客中包含5个最新帖子(仅提取)/wp.

有没有办法包括Wordpress /summary.php并只打印这些帖子的HTML?(也许我应该解析rss?)

Nic*_*ini 9

看看将WordPress与您的网站集成

这是该页面的一个示例,它按字母顺序显示前十个帖子:

<?php
require('/the/path/to/your/wp-blog-header.php');
?>

<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>
Run Code Online (Sandbox Code Playgroud)

使用$posts = get_posts('numberposts=10');,如果你想在10个最新的帖子.