我正在创建一个快捷码,以显示WordPress中具有特定配置文件的用户列表。
但我无法启用或显示分页。我的网站上有25个用户,希望每页显示5个配置文件用户,并包括分页。
我为学生档案添加了一个新角色student和多个使用高级自定义字段的自定义字段。
因此,我需要显示一个学生列表作为适当的字段。到目前为止,问题是我无法启用的分页。
下面是我的代码示例:
add_shortcode(\'list-users\', \'list_users\');
function list_users($atts){
global $wpdb;
$args = array(
\'blog_id\' => \'\',
\'role\' => \'student\',
\'meta_key\' => \'pw_user_status\', //I\'m using the New User Approve Plugin
\'meta_value\' => \'approved\',//If user is denied, he is not appears in the list
\'meta_compare\' => \'\',
\'meta_query\' => array(),
\'include\' => array(),
\'exclude\' => array(),
\'orderby\' => \'display_name\',
\'order\' => \'ASC\',
\'offset\' => \'\',
\'search\' => \'\',
\'number\' => \'2\',
\'count_total\' => true,
\'fields\' => \'all\',
\'who\' => \'\'
);
$students = get_users($args);
if(is_user_logged_in()){
$content = "<div id=\'list-of-users\'>";
foreach($students as $student){
$content .= "<li>";
$content .= "<div class=\\"edit-profile\\">";
if(current_user_can(\'administrator\')){
$link_of_profile_of_user = get_edit_user_link($aluno->ID);
$content .= "<a href=".$link_of_profile_of_user." class=\\"edit-profile\\">"."Edit this profile"."</a>";
}
$content .= "</div>";
$content .= get_avatar($student->ID);
$content .= "<span class=\'item\'>Name: </span>" . get_the_author_meta(\'display_name\', $student->ID) . "<br />";
$content .= "<span class=\'item\'>Date of Birth: </span>" . get_the_author_meta(\'date_of_birth_acf_student\', $student->ID) . "<br />";
$content .= "<span class=\'item\'>Course: </span>" . get_the_author_meta(\'course_acf_student\', $aluno->ID) . "<br />"
$content .= "<span class=\'item\'>Email: </span>" . get_the_author_meta(\'user_email\', $student->ID) . "<br />";
$content .= "<span class=\'item\'>Phone: </span>" . get_the_author_meta(\'phone_acf_student\', $student->ID) . "<br />";
$content .= "<span class=\'item\'>City: </span>" . get_the_author_meta(\'city_acf_student\', $student->ID) . "<br />";
$content .= "</li>";
}//close foreach
$content .= "</div>";
return $content;
}//close the conditional for user logged
}//close function