
如果你的WordPress 2.8使用的Recent comment(最新迴響或最新留言)是系統內建的模組的話,它顯示的格式會是「留言人 在 文章標題」的格式,在此種格式下,必須點擊文章標題的連結,才能看到實際的留言內容,為了能直接顯示留言內容,我修改了下列幾段程式:
- 修改wp-includes\default-widgets.php 第645行,把get_the_title換成get_comment_excerpt;要注意檔案編碼要存成UTF-8,以免中文字變成亂碼:
echo '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s 說 %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_comment_excerpt() . '</a>') . ''; // get_the_title($comment->comment_post_ID) - 因為系統取留言片段的get_comment_excerpt函數是針對拚音文字在處理的,中文不甚適用,因此一併修改wp-includes\comment-template.php 第386行:
function get_comment_excerpt() { global $comment; $comment_text = strip_tags($comment->comment_content); /* $blah = explode(' ', $comment_text); if (count($blah) > 20) { $k = 20; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i=0; $i< $k; $i++) { $excerpt .= $blah[$i] . ' '; $excerpt .= $blah[$i] . ' '; } */ if (strlen($comment_text) > 40) { $excerpt = mb_substr($comment_text,0,40) . '...'; } else { $excerpt = $comment_text; } //$excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt); }##
##
您可能也會有興趣的類似文章
- Step by Step安裝WordPress 3.0與啟用 Multi-Site多站點功能 (14則留言, 2010/07/10)
- WordPress減肥記:壓縮JavaScript檔的大小 (6則留言, 2010/06/08)
- 用jQuery改造WordPress網頁 (2則留言, 2009/10/27)
- 值得參考的WordPress速查表 (0則留言, 2009/01/21)
- 自製WordPress-mu 2.7的繁體中文語言檔[修訂] (10則留言, 2009/02/09)
- WordPress 3.0與PHP 5的時區問題 (1則留言, 2010/06/24)
- [WordPress] 使用Anchor在目前網頁裡瞬間移動 (0則留言, 2008/11/30)
- WordPress簡單又美觀的網站訂閱與文章書籤外掛:Add To Any (1則留言, 2008/12/28)
- 目前使用中的WordPress外掛 (2則留言, 2008/11/29)
- [WordPress 3] 將Twenty Eleven佈景主題加上分頁導航樣式 (0則留言, 2012/01/22)
- WordPress跑馬燈外掛:Running Line (0則留言, 2010/06/10)
- WordPress 2.7可能的漏洞? (2則留言, 2008/12/15)
- WordPress持續減肥-找出使用網站內部圖檔的文章 (0則留言, 2010/06/12)
- 佈景主題Atahualpa 3.5.2增加WordPress 3.0選單功能 (1則留言, 2010/07/21)
- 慎始之:如何挑選適當的WordPress固定網址(Permalink) (2則留言, 2010/07/03)















最新留言