有人可以帮助新手更改 while 以仅列出 x 数量的项目吗?
我的最终目标是列出 10 个帖子......不是 1000 ;)哈哈
我的代码是:
<div class="partner-widget">
<br>
<?php
$author_ID = get_query_var('author');
$t2 = 'cat= 666&author=' . $author_ID . '&order=ASC&showposts=-1';
query_posts($t2);
if(have_posts()) : while(have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><hr>
<?php endwhile; endif; ?>
</div>
最好的方法实际上是更改您的$t2
以限制您的帖子:
$t2 = 'cat= 666&author=' . $author_ID . '&order=ASC&showposts=10';
然后,完整的可能是这样的:
<div class="partner-widget">
<br>
<?php
$author_ID = get_query_var('author');
$t2 = 'cat= 666&author=' . $author_ID . '&order=ASC&showposts=10';
query_posts($t2);
if(have_posts()) : while(have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><hr>
<?php endwhile; endif; ?>
</div>
希望这有帮助。 :)
使用 limit 参数并限制您收到的帖子数量。