Posts Tagged ‘wordpress’

在博客显示我的Twitter记录

星期三, 11月 25th, 2009

写twitter的时候,总有一丝陌生感,一方面来自对饭否的怀念,另一方面来自GFW的阻挡。毕竟,大多数中国人在技术层面上看不到我的twitter。所以心血来潮,在博客上开个页面,用 twitter api 显示我的twitter记录。当然,这样做的前提是,博客要在墙外才行。

大体过程如下:

1.到 http://github.com/jdp/twitterlibphp 下载PHP类库 twitter.lib.php,上传到wordpress的主题路径下。

2.在wordpress的主题里新建一个页面模板,代码如下:

  1. <?php
  2. /*
  3. Template Name: Twitter
  4. */
  5. include(twitter.lib.php);//包含类库
  6.  
  7. $user = username;//twitter账号
  8. $pw = password;//twitter密码
  9.  
  10. $twitter = new Twitter($user,$pw);
  11.  
  12. $statuses = json_decode($twitter->getUserTimeline(array(),json));
  13. //将数据以json格式取出,并用php函数 json_decode 转成对象。其实可以用xml或者rss,但在html中使用的,还是json比较方便。
  14.  
  15. die(print_r($statuses));
  16. //测试一下数据结构,接下来的自己看着办吧。

wordpress 主题 header 优化方案改进版

星期日, 3月 15th, 2009

针对wordpress主题的SEO优化方案,在网上流传的方案基础上进行了改进——

以下代码替代header.php文件相应代码:

  1. <title>
  2. <?php
  3. if (is_single() || is_page() || is_archive()) { wp_title(,true) ; echo | ; }
  4. bloginfo(name);
  5. ?>
  6. </title>
  7.  
  8. <?php
  9. //以下优化搜索引擎对导航页重复内容收录问题:
  10. if (is_single() || is_page() || is_home() ) 
  11.     { echo <meta name="robots" content="index,follow" />; }
  12. else
  13.     { echo <meta name="robots" content="noindex,follow" />; }
  14. //针对baidu对index不准确识别的问题则改用以下代码:
  15. //if ( !(is_home()) and !(is_single()) ) { echo ‘<meta name="Googlebot" content="noindex,follow" />’; }
  16.  
  17. //以下优化description和keywords:
  18. if (is_single()) {
  19.     if ($post->post_excerpt) {
  20.         $description = $post->post_excerpt;
  21.     } else {
  22.         $description = substr(strip_tags($post->post_content),0,220);
  23.     }
  24.     $tags = wp_get_post_tags($post->ID);
  25.     foreach ($tags as $tag ) {
  26.         $keywords = $keywords . $tag->name . ", ";
  27.     }
  28. } elseif(is_category()) {
  29.     $description = category_description();
  30. }
  31.  
  32. if ($keywords) {
  33.     echo <meta name="keywords" content=" . $keywords . " />;
  34. }
  35. if ($description) {
  36.     echo <meta name="description" content=" . $description . " />;
  37. } else {
  38.     echo <meta name="description" content=";
  39.     bloginfo(description);
  40.     echo " />;
  41. }
  42. ?>

新做的一款 wordpress CMS风格主题预览

星期日, 2月 24th, 2008

wordpress cms-style theme jlucc1.0

给单位做的网站,本来用一款asp的cms,但现在只能用php主机,就顺手做了个wordpress主题。

demo: http://www.jlucc.com

该主题主要特点:

  1. 所有页面和分类都在菜单栏上
  2. 标签列表放在菜单栏下面
  3. 首页增加了一个flash新闻幻灯
  4. 首页显示重要分类的更新列表
  5. 增加作者名录
  6. 支持widget

预览:

目前该主题不提供下载,感兴趣的朋友请在评论中索要。

由于种种原因,加之主题完成后一些问题难以解决,决定暂不发放。但评论中的索要依然有效。我会在问题解决后第一时间发放给评论中的email。