嗯....最简单但不是最好的方法是:手动放置一个空的 div 标签,这样你的代码就会变成这样:<nav class= 'woocommerce-MyAccount-navigation'><div style ='blah-blah'>//that div after the nav bar ;TLDR<div id='newDiv></div><ul>//etc包装代码以在 php 函数中显示用户信息、头像和姓名(我命名为 getUsernameAndStuff()),让其id成为用户的 id。喜欢 :<?php function getUsernameAndStuff(id){//put the code here..}?>然后使用js:<script>document.getElementById().innerHTML=<?php getUsernameAndStuff(id)?></script>