Jubayer Hossain

How To Get Username In WordPress Using PHP

To get the current username in wordpress using php you have write this custom code in functions.php

					function getUser(){
	 $current_user = wp_get_current_user();
	$userName = $current_user->display_name;
	<span><i class="fas fa-user"></i>  <?php echo $userName ?></span>
<?php }
And then you can user this shortcode [username] anywhere that you want to output the user name.

Leave a Comment

Your email address will not be published. Required fields are marked *