感謝㊣贊助鼓勵!

Google搜尋 »

分類

簡睿在噗浪»

有朋自遠方來

修改WordPress 2.8最新迴響的顯示格式

H0998

果你的WordPress 2.8使用的Recent comment(最新迴響或最新留言)是系統內建的模組的話,它顯示的格式會是「留言人 在 文章標題」的格式,在此種格式下,必須點擊文章標題的連結,才能看到實際的留言內容,為了能直接顯示留言內容,我修改了下列幾段程式:

  1. 修改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)
  2. 因為系統取留言片段的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);
    }

    ##

##

相關文章

填寫回應

 

 

 

您可使用這些HTML標籤

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

隨機文章

  1. 手動撰寫WordPress隨機文章功能 
  2. [ThunderBird] 寄信時自動壓縮附件 
  3. [轉貼] 美國人最想要的耶誕禮物:華碩Eee PC 
  4. 將IE網頁轉換成FireFox也能執行 
  5. 方便切換目錄的指令:PUSHD與POPD 
  6. ThunderBird擴充: 聯絡人側邊工作列(Sidebars) 
  7. [Windows] 用mklink與junction建立資料夾連結 (3)
  8. 日劇《仁醫 JIN》與漫畫《仁者俠醫》觀後雜感 (10)
  9. 搖手機啟動指定的程式:G-Trigger 
  10. Vista IE8的window.open異常 

歷史熱門文章

  1. Plurk CSS樣式自訂修改全攻略 (30,962 點擊/2009-07-04)
  2. 把HTC Touch HD操作介面換成Spb Mobile Shell,美觀又便利! (20,274 點擊/2009-02-18)
  3. 強化閱讀第2噗:變更噗浪回應的字體與背景顏色 (17,547 點擊/2009-06-07)
  4. 另一套適用手機的影片轉檔工具:WinAVI 3GP/MP4/PSP/iPod Video Converter (16,753 點擊/2009-04-18)
  5. 強化HTC Touch HD的工具軟體 (14,969 點擊/2009-02-25)
  6. 如何手動輸入Plurk的表情圖示? (13,959 點擊/2008-09-29)
  7. 增加Spb Mobile Shell 3.0生活化桌面頁數的小技巧 (13,743 點擊/2009-04-27)
  8. 簡單放大Plurk輸入區的方法[修訂] (13,049 點擊/2008-09-29)
  9. 將Plurk回應區變成固定寬度 (12,873 點擊/2009-07-11)
  10. 將噗浪的視窗高度變大,加上分隔線,以方便閱讀 (12,514 點擊/2009-06-06)