Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在顶部菜单中显示wordpress登录用户名_Php_Wordpress_Authentication - Fatal编程技术网

Php 如何在顶部菜单中显示wordpress登录用户名

Php 如何在顶部菜单中显示wordpress登录用户名,php,wordpress,authentication,Php,Wordpress,Authentication,我需要在我的网站的顶部菜单中显示用户名,但我想在顶部菜单中代替登录。当用户注销时,它将显示登录,当用户登录时,它将显示欢迎用户名,我是WordPress的新手 <?php global $current_user; wp_get_current_user(); ?> <?php if ( is_user_logged_in() ) { echo 'Username: ' . $current_user->user_login . "\n"; echo 'User na

我需要在我的网站的顶部菜单中显示用户名,但我想在顶部菜单中代替登录。当用户注销时,它将显示登录,当用户登录时,它将显示欢迎用户名,我是WordPress的新手

<?php global $current_user; wp_get_current_user(); ?>
<?php if ( is_user_logged_in() ) { 
 echo 'Username: ' . $current_user->user_login . "\n"; echo 'User name: ' . $current_user->display_name . "\n"; 
} 
else { wp_loginout(); } ?>