简体   繁体   English

PHP显示当前页面作者的WordPress帖子列表

[英]PHP to display list of WordPress Posts by Author of the current page

I'm not a pro coder but sometimes I do ok ;) That being said, I'm trying to create some php code to get the current author and then display a list of WordPress posts from category x. 我不是专业程序员,但有时我会做的不错;)话虽如此,我试图创建一些php代码来获取当前作者,然后显示类别x中的WordPress帖子列表。

this code works but is static: 该代码有效,但是是静态的:

<?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

This code works great. 这段代码很棒。 It displays 3 posts. 它显示3个帖子。

So I created this code to make the author based on the author of the page. 因此,我创建了此代码以根据页面的作者来创建作者。 It works but only displays one post. 它有效,但仅显示一个帖子。 It stops after 1... :( Any idea why? 它在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; ?>

change 更改

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

to

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM