这是我的php代码:
<?php global $royal_profile;?>
<div class="profile-img" data-key="profilepicture">
<?php echo get_avatar( get_current_user_id(), 64 ); ?>
</div>
然后,我尝试将其转换为一个短代码(以便我可以在菜单中使用,因为我意识到我不能简单地将php放入菜单中。function wpse_143641_profile_shortcode( $atts ) {
return <<<royal_profile
<?php global $royal_profile;?>
<div class="profile-img" data-key="profilepicture">
<?php echo get_avatar( get_current_user_id(), 64 ); ?>
</div>
royal_profile;
}
add_shortcode( \'royal_profile\', \'wpse_143641_profile_shortcode\' );
当我检查前端的元件时,得到的结果如下。我做错了什么?
谢谢