$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>users - Display recent members|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

users - Display recent members

matteradmin8PV0评论

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>";
Share Improve this question edited Jan 21, 2019 at 15:48 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Jan 21, 2019 at 15:17 Nicolas SursockNicolas Sursock 1 2
  • 1 What does it mean "crashing"? Please edit the question providing enough information. – Max Yudin Commented Jan 21, 2019 at 15:21
  • There is nothing wrong with the above code, it works for me. You must have another error outside of the code you provided. – RiddleMeThis Commented Jan 21, 2019 at 15:25
Add a comment  | 

1 Answer 1

Reset to default 0

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');

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far