什么是在循环中只显示2个帖子的最佳方式?
<?php
$i = 1;
while (have_posts()):
if ($i == 3)
{
break;
}
the_post();
$i++;
endwhile;
?>
Run Code Online (Sandbox Code Playgroud)
有更"美丽"的东西吗?
query_posts('posts_per_page=2');
Run Code Online (Sandbox Code Playgroud)
在循环之前.
摘自文档页面:
query_posts()可用于显示与通常在特定URL上显示的帖子不同的帖子.
| 归档时间: |
|
| 查看次数: |
3361 次 |
| 最近记录: |