WordPress主題教程之修改wordpress回復(fù)評論文字方法,首選需要建立個自定義的評論模板,然后通過調(diào)用此評論函數(shù)來實(shí)現(xiàn)自定義,通過以下代碼可以實(shí)現(xiàn)修改回復(fù)文字:
<span class="sh_symbol"><?</span>php $defaults <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'add_below'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'comment'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'respond_id'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'respond'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'reply_text'</span> <span class="sh_symbol">=></span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'Reply'</span><span class="sh_symbol">),</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'login_text'</span> <span class="sh_symbol">=></span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'Reply'</span><span class="sh_symbol">),</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'depth'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">0</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'before'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'after'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">);</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">comment_reply_link</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array_merge</span><span class="sh_symbol">(</span> $defaults<span class="sh_symbol">,</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'depth'</span> <span class="sh_symbol">=></span> $depth<span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'max_depth'</span> <span class="sh_symbol">=></span> $args<span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'max_depth'</span><span class="sh_symbol">])))</span> <span class="sh_symbol">?></span>
你可以將 Reply 修改成你希望的文字,
如何修改wordpress回復(fù)評論文字
。$defaults <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array</span><span class="sh_symbol">(</span>‘add_below’ <span class="sh_symbol">=></span> ‘comment’<span class="sh_symbol">,</span> ‘respond_id’ <span class="sh_symbol">=></span> ‘respond’<span class="sh_symbol">,</span> ‘reply_text’ <span class="sh_symbol">=></span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span>‘Reply’<span class="sh_symbol">)</span>
這行是默認(rèn)的回復(fù)評論。
‘login_text’ <span class="sh_symbol">=></span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span>‘Reply’<span class="sh_symbol">),</span> ‘depth’ <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">0</span><span class="sh_symbol">,</span> ‘before’ <span class="sh_symbol">=></span> ”<span class="sh_symbol">,</span> ‘after’ <span class="sh_symbol">=></span> ”<span class="sh_symbol">);</span>
這行是登陸后評論。
<span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">comment_reply_link</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array_merge</span><span class="sh_symbol">(</span> $defaults<span class="sh_symbol">,</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array</span><span class="sh_symbol">(</span>‘depth’ <span class="sh_symbol">=></span> $depth<span class="sh_symbol">,</span> ‘max_depth’ <span class="sh_symbol">=></span> $args<span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'max_depth'</span><span class="sh_symbol">])))</span>
這行是評論鏈接。
將以上代碼放在評論 loop 內(nèi)既可使用,下面是完整的 custom_comment.php 函數(shù)文件:
<span class="sh_symbol"><?</span>php <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span> <span class="sh_symbol">(!</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">function_exists</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"custom_comment"</span><span class="sh_symbol">))</span> <span class="sh_cbracket">{</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">function</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">custom_comment</span><span class="sh_symbol">(</span>$comment<span class="sh_symbol">,</span> $args<span class="sh_symbol">,</span> $depth<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span> $GLOBALS<span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'comment'</span><span class="sh_symbol">]</span> <span class="sh_symbol">=</span> $comment<span class="sh_symbol">;</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><</span>li <span class="sh_symbol"><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">comment_class</span><span class="sh_symbol">();</span> <span class="sh_symbol">?>></span> <span class="sh_symbol"><</span>a name<span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"comment-<?php comment_ID() ?>"</span><span class="sh_symbol">></</span>a<span class="sh_symbol">></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_comment_type</span><span class="sh_symbol">()</span> <span class="sh_symbol">==</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">"comment"</span><span class="sh_symbol">)</span><span class="sh_cbracket">{</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">the_commenter_avatar</span><span class="sh_symbol">(</span>$args<span class="sh_symbol">)</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span class="sh_cbracket">}</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php $defaults <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'add_below'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'comment'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'respond_id'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'respond'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'reply_text'</span> <span class="sh_symbol">=></span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'Reply'</span><span class="sh_symbol">),</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'login_text'</span> <span class="sh_symbol">=></span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'Reply'</span><span class="sh_symbol">),</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'depth'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_number">0</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'before'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'after'</span> <span class="sh_symbol">=></span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">);</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">comment_reply_link</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array_merge</span><span class="sh_symbol">(</span> $defaults<span class="sh_symbol">,</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">array</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'depth'</span> <span class="sh_symbol">=></span> $depth<span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'max_depth'</span> <span class="sh_symbol">=></span> $args<span class="sh_symbol">[</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'max_depth'</span><span class="sh_symbol">])))</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">the_commenter_link</span><span class="sh_symbol">()</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php echo <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_comment_date</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_option</span><span class="sh_symbol">(</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'date_format'</span> <span class="sh_symbol">))</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">_e</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'at'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'jintu'</span><span class="sh_symbol">);</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php echo <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_comment_time</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">get_option</span><span class="sh_symbol">(</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'time_format'</span> <span class="sh_symbol">));</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">edit_comment_link</span><span class="sh_symbol">(</span><span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">__</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'Edit'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'jintu'</span><span class="sh_symbol">),</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">''</span><span class="sh_symbol">);</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">comment_text</span><span class="sh_symbol">()</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">if</span> <span class="sh_symbol">(</span>$comment<span class="sh_symbol">-></span>comment_approved <span class="sh_symbol">==</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'0'</span><span class="sh_symbol">)</span> <span class="sh_cbracket">{</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><</span>p <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">class</span><span class="sh_symbol">=</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'unapproved'</span><span class="sh_symbol">><?</span>php <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">_e</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'Your comment is awaiting moderation.'</span><span class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'jintu'</span><span class="sh_symbol">);</span> <span class="sh_symbol">?></</span>p<span class="sh_symbol">></span> <span class="sh_symbol"><?</span>php <span class="sh_cbracket">}</span> <span class="sh_symbol">?></span> <span class="sh_symbol"><?</span>php <span class="sh_cbracket">}</span> <span class="sh_cbracket">}</span> <span class="sh_symbol">?></span>
將上面的代碼保存到 custom_comment.php 文件, 在functions.php里加載即可,wordpress修改回復(fù)文字的方法就這么簡單,試試吧,