由于某种原因,我的作者消失了,我无法再打开它。我知道我想把它放在哪里。php,但我不知道我必须输入什么代码才能显示它。
我怎么才能在帖子上叫出作者的名字呢?
2 个回复
SO网友:Christopher Lamm
author对象上的属性是post\\u author。您可以在循环中这样访问它,其中$post是您的WP\\u post对象。
$author = $post->post_author;
如果要显示它:echo $post->post_author;
SO网友:Nicolai Grossherr
在…内The Loop 您可以使用Template Tag the_author()
显示或get_the_author()
返回相同的。有关外部循环用法的介绍,请参阅Q&;C;A在螺纹处How to get Author ID outside the loop 在这里。
结束