Archive for 6月 2012

轻量级站点统计代码

感谢番茄提供的代码。

<li id="text-5" class="widget widget_text"><h2 class="widgettitle">站点统计</h2>
 <div class="textwidget"></div>
 <div class="widget">
<ul>
 <li>建站时间:2012年06月09日</li>
 <li>网站运行:<?php echo floor((time()-strtotime("2012-06-09"))/86400); ?>天</li>
 <li>文章总数:<?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?></li>
 <li>分类总数:<?php echo $count_categories = wp_count_terms('category'); ?>个</li>
 <li>评论总数:<?php echo $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments");?></li>
 <li>最后更新:<?php $last = $wpdb->get_results("SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = 'post' OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')");$last = date('Y-n-j', strtotime($last[0]->MAX_m));echo $last; ?></li>
 </ul>
</div>
</li>

超轻量级提示留言头像注册代码

写在这里仅供自己日后修改

<label for="email"><?php _e('邮箱', 'kubrick'); ?> <?php if ($req) _e("(必填,绝不会透露)", "kubrick"); ?></label>

替换成

<label for="email">邮箱 * <a id="Get_Gravatar"  title="留言无头像?快去Gravatar注册一个全球通用头像吧!" target="_blank" href="http://en.gravatar.com/">(设置头像)</a></label>

用代码实现wordpress”读者墙”(完美修改版)

前文写到《给博客添加一个”读者墙”,插件wp-reader-wall》,文中也提到了该插件的一些缺点。本着WP fans一贯的折腾的精神,严重浪漫又开始研究起用代码实现读者墙。

一直以来都很喜欢Junan的读者墙,和他聊了一下,得知他的读者墙是代码实现的。于是把代码要来了。使用后,发现有一个小小的问题:点击墙上的头像,会在本页内跳转到别人的博客,这样会造成本博客的“跳出”。于是,我修改了一下,修改后,点击头像,在新页面(或标签)打开别人的博客。这样的话,这段代码就比较完美了。

Continue reading ‘用代码实现wordpress”读者墙”(完美修改版)’ »

WordPress 文章存档插件 WP-EasyArchives

在您的定制页面显示对搜索引擎友好的树形结构存档列表, 适用于 WordPress 2.2 或以上.

WordPress 存档插件, Archives Plugin

插件下载

WP-EasyArchives

Continue reading ‘WordPress 文章存档插件 WP-EasyArchives’ »

wordpress文章浏览次数统计轻量级代码版

首先在functions.php添加两个函数:

//获取浏览数-参数文章ID
function getPostViews($postID)
{
	//字段名称
	$count_key = 'post_views_count';
	//获取字段值即浏览次数
	$count = get_post_meta($postID, $count_key, true);
	//如果为空设置为0
	if($count=='')
	{
		delete_post_meta($postID, $count_key);
		add_post_meta($postID, $count_key, '0');
		return "浏览: 0 次";
	}
	return '浏览: '.$count.' 次';
}
//设置浏览数-参数文章ID
function setPostViews($postID)
{
	//字段名称
	$count_key = 'post_views_count';
	//先获取获取字段值即浏览次数
	$count = get_post_meta($postID, $count_key, true);
	//如果为空就设为0
	if($count=='')
	{
		$count = 0;
		delete_post_meta($postID, $count_key);
		add_post_meta($postID, $count_key, '0');
	}
	else
	{
		//如果不为空,加1,更新数据
		$count++;
		update_post_meta($postID, $count_key, $count);
	}
}

Continue reading ‘wordpress文章浏览次数统计轻量级代码版’ »