WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently calling a user's nicename in a function I have:

   $users = $user_query->get_results();  
   foreach( $users as $user ):    
   echo $user->user_nicename; 

I'm trying to call the user's Nickname instead, but nothing I do is working such as:

    echo $user->user_nickname;

Is there a special way you have to call a user's nickname?


share|improve this question
What does $user_query->get_results() return? – Chip Bennett May 21 '12 at 14:50

If you want to query all users, try using the get_users() function. Note that this function returns an array:

$users = get_users();

foreach( $users as $user ) {
    echo $user['user_nicename'];
share|improve this answer
I have a custom code that provides a list of users based on certain criteria, but I am just not able to successfully call (and display) the user's nickname instead of their nicename. – Teddy May 21 '12 at 14:26
How are we supposed to answer/help, without seeing this "custom code"? – Chip Bennett May 21 '12 at 14:37
I didn't think the code itself was really relevant, I was just asking in general for how to call a user's nickname. – Teddy May 21 '12 at 14:55
Okay, now I'm confused. :) If the code itself isn't really relevant, why did you bring it up? – Chip Bennett May 21 '12 at 15:41
I think I'm confused too... ;) Your original reply mentioned querying all users, which I am not doing. I am just trying to change the way my query displays on my page (using nickname instead of nicename) so that a user's first and last name will appear. – Teddy May 21 '12 at 16:22


echo the_author_meta( 'nickname', $current_user->ID );

or you can also use;

$current_user = wp_get_current_user();
echo $current_user->nickname ;
share|improve this answer
Please explain how to use this with the OP's code. – s_ha_dum Sep 5 '13 at 13:08

This is impossible to answer without seeing your code but there is no user_nickname in the $wpdb->users table and no user_nickname key in the $wpdb->usermeta table by default.

Assuming that $users is a user object then:

$users = $user_query->get_results();  
foreach( $users as $user ) {  
   echo get_user_meta($user->ID,'nickname',true); 

Should get you the user nickname.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.