【发布时间】:2021-06-03 06:06:49
【问题描述】:
我试图通过 get_the_author_meta() 函数在我的 single.php 页面上简单地显示帖子作者的姓名和描述,但是当我用数字填充 id 字段时,我只能让它返回一个值什么不理想,因为作者根据帖子而变化。我真的不明白为什么 wordpress 默认没有获取当前帖子作者的 id。有人可以帮我吗?
这是我正在使用的代码
<div class="col-8 col-md-10">
<?php $id=get_the_author_meta('ID'); echo $id ?>//getting the author's id this way doesn't work
<h2><?php echo get_the_author_meta('nickname',1);?></h2>//this works but only because I filled the id field with a valid number
<p><?php echo get_the_author_meta('user_description') ?></p>//this doesn't workalso
</div>
【问题讨论】: