2016-02-25 86 views
0

我不是一个专业编码员,但有时我确定;)这就是说,我试图创建一些PHP代码来获取当前的作者,然后显示来自类别x的WordPress帖子列表。PHP显示当前页面的作者WordPress的帖子列表

此代码的工作,但是是静态的:

<?php query_posts('cat=665&author=37&order=ASC&showposts=-1'); ?> 
<?php if(have_posts()) : while(have_posts()) : the_post(); ?> 
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br> 
<?php endwhile; endif; ?> code here 

此代码的伟大工程。它显示3个帖子。

所以我创建了这段代码,使作者根据页面的作者。它可以工作,但只显示一个帖子。它停止后1 ... :(任何想法,为什么?

<?php 
$author_ID = get_query_var('author'); 
$t = 'cat=666&author=' . $author_ID . '&order=ASC&showposts=1'; 
query_posts($t); 
if(have_posts()) : while(have_posts()) : the_post(); ?> 
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br> 
<?php endwhile; endif; ?> 

回答

0

变化

$t = 'cat=666&author=' . $author_ID . '&order=ASC&showposts=1'; 

$t = 'cat=666&author=' . $author_ID . '&order=ASC&showposts=-1'; 
+0

THANK YOU SO MUCH!工作完美!:)谢谢! – user2393110

+0

没问题,不客气。 –

+0

对你来说还有一个问题 - 如果我可以的话。我怎样才能改变这个只显示10个帖子?谢谢! – user2393110

相关问题