0

我想知道是否有人新如何在 Wordpress 中显示 3 个最新帖子?任何帮助将非常感激。

只是帖子的缩略图输出3次怎么样?

4

2 回答 2

3

WordPress 有一个内置功能来获取最近的帖子。

wp_get_recent_posts( $args ) ;

$args是您需要传递的参数。要获取最近发布的三个帖子,您可以这样做:

$args = array('numberposts' => 3, 'post_status' => 'publish');
$recent_posts = wp_get_recent_posts( $args ) ;

print_r($recent_posts);

您可以在此链接wp_get_recent_posts上获取更多信息

希望这可以帮助你:)

于 2012-09-26T18:12:22.403 回答
0

您可以使用query_posts

例如,在主页上,您通常会看到最新的 10 个帖子。如果您只想显示 3 个帖子(并且不关心分页),您可以像这样使用 query_posts():

query_posts('posts_per_page=3');

希望这有帮助!

于 2012-09-26T18:16:46.017 回答