wordpress使用笔记

这篇文章用来记录我在使用wordpress中遇到的问题,技巧以及想法.

title keywords description:

在主题文件夹下找到header.php.将以下代码加入或替换原来的内容.

<title><?php if (is_home()||is_search()) { print "this M"; } else { wp_title(''); print " |"; bloginfo('name'); } ?></title>
<?php
if (!function_exists('utf8Substr')) {
 function utf8Substr($str, $from, $len)
 {
     return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
          '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
          '$1',$str);
 }
}
 if (is_home()){
 $description = "this M是小M(HB6H057)的个人主页.";   
 $keywords = "M,密码,算法,博客,黑客";
} elseif (is_single()){
    if ($post->post_excerpt) {
        $description  = $post->post_excerpt;
    } else {
   if(preg_match('/<p>(.*)<\/p>/iU',trim(strip_tags($post->post_content,"<p>")),$result)){
    $post_content = $result['1'];
   } else {
    $post_content_r = explode("\n",trim(strip_tags($post->post_content)));
    $post_content = $post_content_r['0'];
   }
         $description = utf8Substr($post_content,0,180);  
  }
 
    $keywords = "";     
    $tags = wp_get_post_tags($post->ID);
    foreach ($tags as $tag ) {
        $keywords = $keywords . $tag->name . ",";
    }
 
}
 
?>
<meta name="description" content="<?php echo trim($description); ?>" />
<meta name="keywords" content="<?php echo rtrim($keywords,','); ?>" />

Meta信息监测: http://tool.chinaz.com/Tools/MetaCheck.aspx

插件:

Akismet : 用于拦截垃圾评论(key:defe740c8db9)

WP-T-Wap: wordpress的wap插件,手机管理博客靠他啦.

Ozh’ Admin Drop Down Menu : 把后台管理菜单改成比较和谐的状态!

Google XML Sitemaps: 谷歌网站地图插件(sitemap.xml)

Baidu Sitemap Generator : 百度网站地图插件(sitemap_baidu.xml,sitemap.html)

cos-html-cache:静态化插件

WP-Syntax:代码高亮插件

WP-Syntax Button:将WP-Syntax 插件加入wordpress编辑器中.

Revision Control:修订控制插件

统计代码:

我打算使用Google Analytics 的,可惜我English不是很好,所以就用CNZZ的咯.用之前要修改一下代码,为了隐藏”站长统计”字样和通过W3c验证.以下代码把X改成CNZZ的ID,建议放在footer.php

<div style=”display:none”>

<script language=”javascript” type=”text/javascript” src=”http://s7.cnzz.com/stat.php?id=X&amp;web_id=X“></script>

</div>

Tags:

2 Responses to “wordpress使用笔记”

  1. KEVIN Says:

    搞链接不??

    回访..

    [回复]

  2. bikes Says:

    bikes Hey, Admin, I am starting my own blog, I was wondering which blog platform you are using? Sorry for the noob question and thanks for you help in advance. I enjoyed your site by the way….

    Hey, Admin, I am starting my own blog, I was wondering which blog platform you are using? Sorry for the noob question and thanks for you help in advance. I enjoyed your site by the way….

Leave a Reply