简体   繁体   中英

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.

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.

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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