国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > Wordpress > 正文

WordPress文章顯示評論內容而不是標題

2024-09-07 00:50:17
字體:
來源:轉載
供稿:網友

我們的wordpress默認情況下只顯示評論的標題而不是顯示評論內容,下面我來調整一下讓wordpress顯示評論內容吧,具體操作步驟如下.

首先找到根目錄下的 wp_includes/default-widgets.php,在functionwidget`(第625行左右)里面找到以下代碼(第655行左右):

  1. if ( $comments ) { 
  2.      foreach ( (array$comments as $comment) { 
  3.      $output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment 
  4. author, 2: post link */ sprintf(_x('%1$s on %2$s''widgets'), get_comment_author_link(), 
  5. '<a  href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title 
  6. ($comment->comment_post_ID) . '</a>') . '</li>'
  7.      } 

將第三行中的如下代碼:

get_the_title($comment->comment_post_ID) 改成 strip_tags( $comment->comment_content),

同時將sprintf里的on改成你想要顯示的文字,如『說』,這樣樣式就變成『評論者』說『評論內容』 以下是修改后的代碼(注意:修改代碼前請先備份)

實例代碼如下:

  1. if ( $comments ) { 
  2.      foreach ( (array$comments as $comment) { 
  3.      $output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment 
  4. author, 2: post link */ sprintf(_x('%1$s said: %2$s''widgets'), get_comment_author_link 
  5. (), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . strip_tags 
  6. (($comment->comment_content) . '</a>') . '</li>'
  7.      } 
其實這個$output就是輸出html代碼,所以可以在此根據自己的需要作出修改.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昭通市| 衢州市| 嘉兴市| 江津市| 无极县| 罗甸县| 咸阳市| 襄樊市| 东丰县| 镶黄旗| 五华县| 临澧县| 兴海县| 敖汉旗| 隆化县| 文水县| 揭阳市| 西华县| 如皋市| 长治市| 伊通| 河池市| 洛宁县| 石景山区| 龙里县| 新巴尔虎右旗| 车致| 资溪县| 西畴县| 偃师市| 青田县| 西华县| 塔河县| 凤城市| 平遥县| 客服| 临湘市| 合江县| 秀山| 安吉县| 石门县|