【问题标题】:PHP to display list of WordPress Posts by Author of the current pagePHP 显示当前页面作者的 WordPress 帖子列表
【发布时间】:2016-02-26 03:58:00
【问题描述】:

我不是专业编码员,但有时我做得很好;)话虽如此,我正在尝试创建一些 php 代码来获取当前作者,然后显示来自类别 x 的 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; ?>

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    改变

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

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

    【讨论】:

    • 再问你一个问题——如果可以的话。如何将其更改为最多仅显示 10 个帖子?谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 1970-01-01
    • 2012-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多