how to get display name in wordpress

You can get the display name in WordPress by using the following code:

$current_user = wp_get_current_user(); $display_name = $current_user->display_name; echo $display_name;

Explanation: 1. $current_user = wp_get_current_user(); - This line retrieves the current user's information. 2. $display_name = $current_user->display_name; - This line assigns the display name of the current user to the variable $display_name. 3. echo $display_name; - This line displays the user's display name on the webpage.