我创造了一个作家。php显示作者的帖子,并分页。单击“下一步”按钮时,我会进入第二页,但使用的模板不同。有什么原因吗?
My query in author.php
$curauth = (get_query_var(\'author_name\')) ? get_user_by(\'slug\', get_query_var(\'author_name\')) : get_userdata(get_query_var(\'author\'));
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
$args = array(
\'author\' => $curauth->ID,
\'orderby\' => \'post_date\',
\'order\' => \'DSC\',
\'paged\' => $paged,
\'post_type\' => \'post\',
\'posts_per_page\' => 1, // there are more
);
$authors_posts = new WP_Query( $args );
Links:
<?php echo get_next_posts_link( \'Next\', $authors_posts->max_num_pages ); ?>
<?php echo get_previous_posts_link( \'Previous\' ); ?>
SO网友:Nuno Sarmento
这不是为您的问题修复的,只是您可以为作者使用的一个工作示例。php页面。
<?php
$number = 10;
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
$offset = ($paged - 1) * $number;
$users = get_users();
$query = get_users(\'&offset=\'.$offset.\'&number=\'.$number);
$total_users = count($users);
$total_query = count($query);
$total_pages = intval($total_users / $number) + 1;
echo \'<ul id="users">\';
foreach($query as $q) { ?>
<li class="user clearfix">
<div class="user-avatar">
<?php echo get_avatar( $q->ID, 80 ); ?>
</div>
<div class="user-data">
<h4 class="user-name">
<a href="<?php echo get_author_posts_url($q->ID);?>">
<?php echo get_the_author_meta(\'display_name\', $q->ID);?>
</a>
</h4>
<?php if (get_the_author_meta(\'description\', $q->ID) != \'\') : ?>
<p><?php echo get_the_author_meta(\'description\', $q->ID); ?></p>
<?php endif; ?>
</div>
</li>
<?php }
echo \'</ul>\';
?>
<?php
if ($total_users > $total_query) {
echo \'<div id="pagination" class="clearfix">\';
echo \'<span class="pages">Pages:</span>\';
$current_page = max(1, get_query_var(\'paged\'));
echo paginate_links(array(
\'base\' => get_pagenum_link(1) . \'%_%\',
\'format\' => \'page/%#%/\',
\'current\' => $current_page,
\'total\' => $total_pages,
\'prev_next\' => false,
\'type\' => \'list\',
));
echo \'</div>\';
?>
您还需要调整css类以匹配您的主题样式