国内外主机
测评及优惠码

WordPress文章如何在评论留言时“文本作者”提示?

WordPress文章如何在评论留言时“文本作者提示?可以让读者给WordPress文章评论时得到作者本人留言时,在名称后面显示“文本作者”提示,让读者能够明确知道是作者本人回复的。具体操作方法如下:

WordPress文章如何在评论留言时“文本作者”提示?

首先将下面判断文章作者代码添加到当前WordPress主题函数模板functions.php中:

// 判断文章作者  function zm_comment_by_post_author( $comment = null ) {  	if ( is_object( $comment ) && $comment->user_id > 0 ) {  		$user = get_userdata( $comment->user_id );  		$post = get_post( $comment->comment_post_ID );  		if ( ! empty( $user ) && ! empty( $post ) ) {  			return $comment->user_id === $post->post_author;  		}  	}  	return false;  }

将显示调用代码添加到主题评论模板显示评论者名称代码的后面即可。

文章作者';  	}  ?>

不同主题评论模板代码不同,具体加到哪个位置,只能自行研究了。

同时显示管理员和作者的调用方法:

comment_author_email == get_option('admin_email')) {  		echo '博主';  	} else {  		$post_author = zm_comment_by_post_author( $comment );  		if ( $post_author ) {  			echo '';  		}  	}  ?>

以上就是小编为大家分享的关于在WordPress文章评论留言时留下“文本作者”提示的方法。

 

赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《WordPress文章如何在评论留言时“文本作者”提示?》
文章链接:https://www.ibytx.com/2415.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

登录

找回密码

注册