<div class="content14">
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT: 14px/22px 宋体; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> wordpress主题教程之修改wordpress回复评论文字方法,首选需要建立个自定义的评论模板,然后通过调用此评论函数来实现自定义,通过以下代码可以实现修改回复文字:
<pre style="BORDER-BOTTOM: rgb(187,187,187) 1px dashed; BORDER-LEFT: rgb(187,187) 5px solid; PADDING-BOTTOM: 3px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255); TEXT-INDENT: 0px; MARGIN: 8px; PADDING-LEFT: 3px; WIDTH: 600px; PADDING-RIGHT: 3px; FONT: 14px/22px Consolas,Monaco,"Bitstream Vera Sans Mono","Courier New",Courier,monospace; WORD-WRAP: break-word; WHITE-SPACE: pre-wrap; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0); BORDER-TOP: rgb(187,187) 1px dashed; BORDER-RIGHT: rgb(187,187) 1px dashed; WORD-SPACING: 0px; PADDING-TOP: 3px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="sh_javascript sh_sourceCode" name="code"><span class="sh_symbol"><?PHP
$defaults <span class="sh_symbol">= <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">array<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'add_below' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'comment'<span class="sh_symbol">, <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'respond_id' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'respond'<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'reply_text' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function"><span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'Reply'<span class="sh_symbol">),
<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'login_text' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(0,255); FONT-WEIGHT: normal" class="sh_string">'depth' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_number">0<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'before' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">''<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'after' <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">''<span class="sh_symbol">);
<span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">comment_reply_link<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">array_merge<span class="sh_symbol">( $defaults<span class="sh_symbol">, <span style="FONT-STYLE: normal; COLOR: rgb(0,255); FONT-WEIGHT: normal" class="sh_string">'depth' <span class="sh_symbol">=> $depth<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'max_depth' <span class="sh_symbol">=> $args<span class="sh_symbol">[<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'<span class="sh_symbol">]))) <span class="sh_symbol">?>
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> 你可以将 Reply 修改成你希望的文字。
<pre style="BORDER-BOTTOM: rgb(187,187) 1px dashed; WORD-SPACING: 0px; PADDING-TOP: 3px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="sh_javascript sh_sourceCode" name="code">$defaults <span class="sh_symbol">= <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">array<span class="sh_symbol">(‘add_below’ <span class="sh_symbol">=> ‘comment’<span class="sh_symbol">, ‘respond_id’ <span class="sh_symbol">=> ‘respond’<span class="sh_symbol">, ‘reply_text’ <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">__<span class="sh_symbol">(‘Reply’<span class="sh_symbol">)
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> 这行是默认的回复评论。
<pre style="BORDER-BOTTOM: rgb(187,187) 1px dashed; WORD-SPACING: 0px; PADDING-TOP: 3px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="sh_javascript sh_sourceCode" name="code">‘login_text’ <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function"><span class="sh_symbol">(‘Reply’<span class="sh_symbol">), ‘depth’ <span class="sh_symbol">=> <span style="FONT-STYLE: normal; COLOR: rgb(255, ‘before’ <span class="sh_symbol">=> ”<span class="sh_symbol">, ‘after’ <span class="sh_symbol">=> ”<span class="sh_symbol">);
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> 这行是登陆后评论。
<pre style="BORDER-BOTTOM: rgb(187,187) 1px dashed; WORD-SPACING: 0px; PADDING-TOP: 3px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="sh_javascript sh_sourceCode" name="code"><span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">array<span class="sh_symbol">(‘depth’ <span class="sh_symbol">=> $depth<span class="sh_symbol">, ‘max_depth’ <span class="sh_symbol">=> $args<span class="sh_symbol">[<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'<span class="sh_symbol">])))
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> 这行是评论链接。
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> 将以上代码放在评论 loop 内既可使用,下面是完整的 custom_comment.PHP 函数文件:
<pre style="BORDER-BOTTOM: rgb(187,187) 1px dashed; WORD-SPACING: 0px; PADDING-TOP: 3px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="sh_javascript sh_sourceCode" name="code"><span class="sh_symbol"><?PHP
<span style="FONT-STYLE: normal; COLOR: rgb(165,42,42); FONT-WEIGHT: normal" class="sh_keyword">if <span class="sh_symbol">(!<span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">function_exists<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">"custom_comment"<span class="sh_symbol">)) <span class="sh_cbracket">{
<span style="FONT-STYLE: normal; COLOR: rgb(165,42); FONT-WEIGHT: normal" class="sh_keyword">function <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">custom_comment<span class="sh_symbol">($comment<span class="sh_symbol">, $args<span class="sh_symbol">, $depth<span class="sh_symbol">) <span class="sh_cbracket">{
$GLOBALS<span class="sh_symbol">[<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'comment'<span class="sh_symbol">] <span class="sh_symbol">= $comment<span class="sh_symbol">; <span class="sh_symbol">?>
<span class="sh_symbol"><li <span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">comment_class<span class="sh_symbol">(); <span class="sh_symbol">?>>
<span class="sh_symbol"><a name<span class="sh_symbol">=<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">"comment-<?php comment_ID() ?>"<span class="sh_symbol">></a<span class="sh_symbol">>
<span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(165,42); FONT-WEIGHT: normal" class="sh_keyword">if<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">get_comment_type<span class="sh_symbol">() <span class="sh_symbol">== <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">"comment"<span class="sh_symbol">)<span class="sh_cbracket">{ <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">the_commenter_avatar<span class="sh_symbol">($args<span class="sh_symbol">) <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP <span class="sh_cbracket">} <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP
$defaults <span class="sh_symbol">= <span style="FONT-STYLE: normal; COLOR: rgb(0,255); FONT-WEIGHT: normal" class="sh_string">'max_depth'<span class="sh_symbol">]))) <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">the_commenter_link<span class="sh_symbol">() <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP echo <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">get_comment_date<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">get_option<span class="sh_symbol">( <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'date_format' <span class="sh_symbol">)) <span class="sh_symbol">?> <span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">_e<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'at'<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'jintu'<span class="sh_symbol">); <span class="sh_symbol">?> <span class="sh_symbol"><?PHP echo <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">get_comment_time<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(0,255); FONT-WEIGHT: normal" class="sh_string">'time_format' <span class="sh_symbol">)); <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">edit_comment_link<span class="sh_symbol">(<span style="FONT-STYLE: normal; COLOR: rgb(0,255); FONT-WEIGHT: normal" class="sh_string">'Edit'<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'jintu'<span class="sh_symbol">),255); FONT-WEIGHT: normal" class="sh_string">''<span class="sh_symbol">); <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,0); FONT-WEIGHT: bold" class="sh_function">comment_text<span class="sh_symbol">() <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(165,42); FONT-WEIGHT: normal" class="sh_keyword">if <span class="sh_symbol">($comment<span class="sh_symbol">->comment_approved <span class="sh_symbol">== <span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'0'<span class="sh_symbol">) <span class="sh_cbracket">{ <span class="sh_symbol">?>
<span class="sh_symbol"><p <span style="FONT-STYLE: normal; COLOR: rgb(165,42); FONT-WEIGHT: normal" class="sh_keyword">class<span class="sh_symbol">=<span style="FONT-STYLE: normal; COLOR: rgb(255,255); FONT-WEIGHT: normal" class="sh_string">'unapproved'<span class="sh_symbol">><?PHP <span style="FONT-STYLE: normal; COLOR: rgb(0,255); FONT-WEIGHT: normal" class="sh_string">'Your comment is awaiting moderation.'<span class="sh_symbol">,255); FONT-WEIGHT: normal" class="sh_string">'jintu'<span class="sh_symbol">); <span class="sh_symbol">?></p<span class="sh_symbol">>
<span class="sh_symbol"><?PHP <span class="sh_cbracket">} <span class="sh_symbol">?>
<span class="sh_symbol"><?PHP
<span class="sh_cbracket">}
<span class="sh_cbracket">} <span class="sh_symbol">?>
<p style="PADDING-BOTTOM: 5px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,0); WORD-SPACING: 0px; PADDING-TOP: 5px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"> 将上面的代码保存到 custom_comment.PHP 文件, 在functions.PHP里加载即可,wordpress修改回复文字的方法就这么简单,试试吧。 原文链接:https://www.f2er.com/wordpress/15433.html