用WordPress搭建类Twitter微博客

Twitter很火,WordPress也很火,这篇文章就教大家使用WordPress搭建类Twitter的微博客。

具体做法:
一,在博客根目录找到:wp-config.php
加入一下代码:
define('WP_POST_REVISIONS', false);//主要作用是让ID连续

二,上传并启用两个插件:
1,wp-pagenavi:分页链接。
2,super-switch:主要作用是让ID连续。

三,找到:
wp-includes/functions.php,加入以下代码:
//count 1 day post count1day()
function count1day()
{
global $wpdb;
$strsql = "SELECT count( ID ) AS c FROM wp_posts WHERE post_date > SUBDATE(NOW(),INTERVAL 1 day)" ;
$xxooxx = $wpdb->get_var($strsql);
return $xxooxx;
}
//count 1 day post count1day()
//count 1 week post count1week()
function count1week()
{
global $wpdb;
$strsql = "SELECT count( ID ) AS c FROM wp_posts WHERE post_date > SUBDATE(NOW(),INTERVAL 1 week)" ;
$xxooxx = $wpdb->get_var($strsql);
return $xxooxx;
}
//count 1 week post count1week()
//count post
function countsend()
{
global $wpdb;
$strsql = "SELECT count( ID ) AS c FROM wp_posts" ;
$xxooxx = $wpdb->get_var($strsql);
return $xxooxx;
}
//count post

四,找到:wp-includes/general-template.php
加入以下代码:
//内页标题输出带一部分正文
//$title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );//原代码 替换成以下
$title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) ).":".strip_tags( apply_filters( 'single_post_content', $post->post_content ) );
if(strlen($title) > 120)
$title = mb_substr($title,0,120,'UTF-8')."...";

操作记录作者也整理了一份,点击下载

效果可以查看DEMO:http://tarr.cn/blog/