马春杰杰 Exit Reader Mode

WordPress修改默认作者评论通知模板

正常的作者通知模板太不友好了,看到标题,你永远不知道内容是什么。所以需要修改下这个,让它最好在标题就告诉你评论的内容。

文件位置在:wp-includes/pluggable.php

打开之后定位到New comment on your post "%s"这句话,然后将这段修改为下面:

                         default: // Comments
			    $notify_message = sprintf( __( $comment_content )) . "\r\n\r\n";
				/* translators: %s: post title */
				$notify_message .= sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
				/* translators: 1: comment author's name, 2: comment author's IP address, 3: comment author's hostname */
				$notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
				/* translators: %s: comment author email */
				$notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
				/* translators: %s: trackback/pingback/comment author URL */
				$notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
				/* translators: %s: comment text */
				$notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
				$notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
				/* translators: Comment notification email subject. 1: Site title, 2: Post title */
				$subject = sprintf( __( '[%1$s] %2$s Comment: "%3$s"' ), $blogname, $comment_content, $post->post_title );
				break;

这样就会在邮件的标题以及正文第一句提示评论的内容了。

本文最后更新于2021年6月28日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!