is\\u author()仅用于存档页。抄本引述:
is\\u author()检查是否显示作者存档页
因此,查看单个帖子或页面并不能从is\\u author()获得一个TRUE。
我想你会想要这样的东西:
global $post,$current_user; // get the global variables to check
get_currentuserinfo(); // get current user info
// Now check if the author of this post is the same as the current logged in user
if ($post->post_author == $current_user->ID) {
// do code here
}
我希望这能有所帮助。:)
编辑#1:缩短代码版本。
// Check if the author of this post is the same as the current logged in user
if ( $post->post_author == get_current_user_id() ) {
// do code here
}