我想我已经差不多做到了,但是我无法获得分页链接来显示我正在创建的作者目录。
下面是我的代码,但我不知道如何获得链接,以便在作者页面之间导航。有人能帮我吗?我觉得这可能有用,但我不知道如何实现它:
谢谢Osu
<?php
/* ****************************************************************** */
/* !LIST AUTHORS */
/* ****************************************************************** */
// THANKS TO:
// http://www.mattvarone.com/wordpress/list-users-with-wp_user_query/
// pagination
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1; // Needed for pagination
$paged -= 1;
$limit = 2;
$offset = $paged * $limit;
// prepare arguments
$args = array(
// search only for Authors role
\'role\' => \'Subscriber\',
// order results by display_name
\'orderby\' => \'display_name\',
// return all fields
\'fields\' => \'all_with_meta\',
\'number\' => $limit,
\'offset\' => $offset
);
// Create the WP_User_Query object
$wp_user_query = new WP_User_Query($args);
// Get the results
$authors = $wp_user_query->get_results();
// Check for results
if (!empty($authors))
{
echo \'<div class="author-entry">\';
// loop trough each author
foreach ($authors as $author)
{
$author_info = get_userdata($author->ID); ?>
<span style="float:left;padding:0 5px 0 0;"><?php echo get_avatar( $author->ID, 50 ); /* http://codex.wordpress.org/Function_Reference/get_avatar */ ?></span>
<span class="fn"><strong>First name</strong> : <?php echo $author_info->first_name; ?></span><br />
<span class="ln"><strong>Last name</strong> : <?php echo $author_info->last_name; ?></span><br />
<span class="em"><strong>Email address</strong> : <a href="mailto:<?php echo $author_info->user_email; ?>"><?php echo $author_info->user_email; ?></a></span><br />
<span class="we"><strong>Website</strong> : <a href="<?php echo $author_info->user_url; ?>"><?php echo $author_info->user_url; ?></a></span><br />
<span class="de"><strong>Bio</strong> :<br /><?php echo $author_info->description ; ?></span>
<div class="clear"> </div>
<?php
}
echo \'</div>\';
} else {
echo \'No authors found\';
}
?>
<?php /* WHAT DO I PUT HERE TO CREATE THE PAGINATION LINKS? */ ?>