嗨,正如我在上一个问题中提到的,我正在学习 php 中的类和方法,所以我还有另一个问题要了解如何使用此查询方法在主题中输出结果。
我目前正在尝试使用 WordPress,所以请考虑一下。然而,它对于 WordPress 而不是太通用,而是逻辑。
<?php
class get_user_widget
{
// other mentods are here which is not related to below method
public static function get_users() {
global $wpdb;
$query = "SELECT id, user_login FROM $wpdb->users ORDER BY user_registered DESC";
$users = $wpdb->get_results($query);
// here I am using foreach so is it okay or while loop is right to use?
foreach ($users as $users)
$rs[] = $users;
return count($rs) ? $rs : array();
}
}
?>
那么如何在主题中使用它来按注册日期呈现用户的输出列表呢?我已经检查了 print_r() 和连接,一切都很好,并且在数组中得到输出,但需要使用 html。
非常感谢..