中文 WordPress 工具箱的熱門文章
我用的Wordpress外掛「中文 WordPress 工具箱」裡面有顯示「評論最多的帖子」這個功能,也就是我的網站右手邊的「熱門文章」區塊。但是他會包含頁面,如我的花履歷以及留言版,都是用獨立的頁面做成的,這樣一來留言版也會出現在熱門文章裡頭,非常的不合邏輯。另外最新文章這一區塊也有這個問題,再怎麼說「留言板」都不應該當成是文章啊!所以我動手修改了這個外掛。
第103行
$mostcommenteds = $wpdb->get_results("SELECT $tableposts.ID as ID, post_title, post_name, COUNT($tablecomments.comment_post_ID) AS 'comment_total' FROM $tableposts LEFT JOIN $tablecomments ON $tableposts.ID = $tablecomments.comment_post_ID WHERE comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' AND post_status = 'publish' AND post_password = '' GROUP BY $tablecomments.comment_post_ID ORDER BY comment_total DESC LIMIT $limit");
改成這樣:
$mostcommenteds = $wpdb->get_results("SELECT $tableposts.ID as ID, post_title, post_name, COUNT($tablecomments.comment_post_ID) AS 'comment_total' FROM $tableposts LEFT JOIN $tablecomments ON $tableposts.ID = $tablecomments.comment_post_ID WHERE comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s", (time() + ($time_difference * 3600)))."' AND post_status = 'publish' AND post_type = 'post' AND post_password = '' GROUP BY $tablecomments.comment_post_ID ORDER BY comment_total DESC LIMIT $limit");
第174行
$request = "SELECT ID, post_title, post_date, post_content FROM $tableposts WHERE post_status = 'publish' ";
改成這樣:
$request = "SELECT ID, post_title, post_date, post_content FROM $tableposts WHERE post_status = 'publish' AND post_type = 'post' ";
若你沒有修改其他任何地方,可以直接下載我的修改版,mulberrykit.php.txt,下載完後把檔名最後面的.txt刪掉,也就是說把 mulberrykit.php.txt改成mulberrykit.php,然後覆蓋到你的Plugins資料夾,就可以了。
- 人氣(1933)
Recent Comments
熱門內容
- Drupal | 用hook_menu_alter來修改tab項目 (192,711)
- 第一次玩弄Drupal就不上手 (183,800)
- 六個網站測速工具 (103,109)
- Drupal 的 Eye Candy? (71,120)
- Introduction to Drupal 簡報分享 (35,917)













回應
發表新回應