2012-09-26 25 views

回答

0

您可以使用query_posts

例如,在主頁上,您通常會看到最新的10個帖子。如果你只想顯示3個帖子(並且不關心分頁),你可以使用query_posts()像這樣:

query_posts('posts_per_page = 3');

希望得到這個幫助!

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

希望這有助於你:)

相關問題