How to Show the Logged in Username in the WordPress
You can use the following code to display the logged-in username in WordPress:
<?php
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
echo 'Welcome, ' . $user->user_login . '!';
}
?>