[英]PHP to display list of WordPress Posts by Author of the current page
我不是專業程序員,但有時我會做的不錯;)話雖如此,我試圖創建一些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; ?>
更改
$t = 'cat=666&author=' . $author_ID . '&order=ASC&showposts=1';
至
$t = 'cat=666&author=' . $author_ID . '&order=ASC&showposts=-1';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.