更改主机后 give_profile_name() 错误缺少参数 1

Missing argument 1 for give_profile_name() error after changing host

我最近更换了主机。之后我看到一个错误。我在 Displaying Logged-In User Name in Wordpress Menu 使用了一段代码 显示用户名而不是 'profile page'。在之前的主机上 运行 没问题。复制所有内容和数据后,我在菜单栏上看到此错误。用户在登录时会看到此信息。请提出补救措施。

以下是我使用的代码。它与我发布的 Whosebug link 上给出的完全相同。正如 link.

中所述,我创建了一个页面 #profile_name#
function give_profile_name($atts){
$user=wp_get_current_user();
$name=$user->user_firstname .' '. $user->user_lastname ; 
return $name;
}

add_shortcode('profile_name', 'give_profile_name');

add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
function my_dynamic_menu_items( $menu_items ) {
foreach ( $menu_items as $menu_item ) {
    if ( '#profile_name#' == $menu_item->title ) {
        global $shortcode_tags;
        if ( isset( $shortcode_tags['profile_name'] ) ) {
            // Or do_shortcode(), if you must.
            $menu_item->title = call_user_func( $shortcode_tags['profile_name'] );
        }    
    }
}

return $menu_items;
} 

不确定您是否仍能回答这个问题,但我想无论如何我都会回复,因为我 运行 在尝试将用户的名字添加到导航菜单时使用相同的代码片段遇到了同样的错误。我注意到尽管有错误它仍然在工作,所以在尝试之后,我只是从函数中删除了 $atts 。所以第一段代码是:

function give_profile_name(){
$user=wp_get_current_user();
$name=$user->user_firstname .' '. $user->user_lastname ; 
return $name;
}