I have the following code who should work fine. But Wordpress is crashing. What's wrong?
echo "<ul>";
$usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
foreach ($usernames as $username) {
echo '<li><a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
}
echo "</ul>";
I have the following code who should work fine. But Wordpress is crashing. What's wrong?
echo "<ul>";
$usernames = $wpdb->get_results("SELECT user_nicename, user_url FROM $wpdb->users ORDER BY ID DESC LIMIT 5");
foreach ($usernames as $username) {
echo '<li><a href="'.$username->user_url.'">'.$username->user_nicename."</a></li>";
}
echo "</ul>";
You should try using the get_users
function.
https://codex.wordpress/Function_Reference/get_users
Example:
get_users('orderby=meta_value&meta_key=user_registered');