<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>不亦乐乎 &#187; Wordpress</title>
	<atom:link href="http://www.happyet.org/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://www.happyet.org</link>
	<description>自娱自乐，不亦乐乎!</description>
	<lastBuildDate>Wed, 08 Sep 2010 08:41:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress 3.0五大新特征</title>
		<link>http://www.happyet.org/439.html</link>
		<comments>http://www.happyet.org/439.html#comments</comments>
		<pubDate>Mon, 21 Jun 2010 04:17:47 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[WordPress 3.0]]></category>
		<category><![CDATA[功能]]></category>
		<category><![CDATA[新特征]]></category>

		<guid isPermaLink="false">http://www.happyet.org/439.html</guid>
		<description><![CDATA[WordPress作为最受欢迎的博客平台，它给用户提供了各种工具，用户可以使用这些工具发布文章、与读者保持互动。不过，更让人高兴的是，本月即将推出的WordPress3.0使得它更加接近CMS内容管理系统。
尽管WordPress3.0与上一个版本相比，改变并没有很多，不过却是非常有意义，特别是对于希望将WordPress当成一个内容管理系统来使用的用户。 本文将对即将发布WordPress3.0最为突出的五个新特征进行简要介绍。
1. 自定义发布内容的类型
默认情况下，WordPress里可以让你发布两种类型的内容：“文章（Posts）”和 “页面（Pages）”。 在WordPress3.0版本中，你可以依据内容本身的属性特征定义更多的内容类型。例如，如果你为一家设计公司开发一个WordPress网站，你就很可能需要创建一个自定义的内容类型来显示“成果一览”、一个员工页面以及一个客户感言等。那么，你就可以在WordPress中通过自定义主题使其更好地服务每一种类型的内容。
在WordPress3.0中你可以轻松地创建自定义各种类型的内容，包括：文本、图片、报价、链接、聊天、音频、视频。
目前只能通过添加插件Custom Post Type UI、插件CMS Press和在主题functions.php文件里添加代码实现该功能，3.0后台并没有可以直接使用的。
比如在functions.php文件里添加如下代码就可以得到一个movie类型的内容：

1
2
3
4
5
6
7
8
9
10
11
12
13
// 创建叫做“movie”类型的内容 
register_post_type&#40;'movies', array&#40;
'label' =&#62; 'Movies', 
'public' =&#62; true,
'show_ui' =&#62; true, 
'capability_type' =&#62; 'post',
'hierarchical' =&#62; false, 
'rewrite' =&#62; array&#40;'slug' =&#62; 'movies'&#41;, 
'query_var' =&#62; true, 
'supports' =&#62; array&#40; 
'title', 'editor', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'thumbnail', 'author', 'page-attributes',&#41; 
&#41; 
&#41;;

这是另一种代码写法，比如创建一个名为“Portfolio（作品集）”的新文章类型：

1
2
3
4
5
6
function post_type_portfolio&#40;&#41; &#123;
    register_post_type&#40; 'Portfolio',
  [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress作为最受欢迎的博客平台，它给用户提供了各种工具，用户可以使用这些工具发布文章、与读者保持互动。不过，更让人高兴的是，本月即将推出的WordPress3.0使得它更加接近CMS内容管理系统。</p>
<p>尽管WordPress3.0与上一个版本相比，改变并没有很多，不过却是非常有意义，特别是对于希望将WordPress当成一个内容管理系统来使用的用户。 本文将对即将发布WordPress3.0最为突出的五个新特征进行简要介绍。</p>
<p><strong>1. 自定义发布内容的类型</strong></p>
<p>默认情况下，WordPress里可以让你发布两种类型的内容：“文章（Posts）”和 “页面（Pages）”。 在WordPress3.0版本中，你可以依据内容本身的属性特征定义更多的内容类型。例如，如果你为一家设计公司开发一个WordPress网站，你就很可能需要创建一个自定义的内容类型来显示“成果一览”、一个员工页面以及一个客户感言等。那么，你就可以在WordPress中通过自定义主题使其更好地服务每一种类型的内容。</p>
<p>在WordPress3.0中你可以轻松地创建自定义各种类型的内容，包括：文本、图片、报价、链接、聊天、音频、视频。</p>
<p>目前只能通过添加插件<a href="http://wordpress.org/extend/plugins/custom-post-type-ui/" target="_blank">Custom Post Type UI</a>、插件<a href="http://wordpress.org/extend/plugins/cms-press/" target="_blank">CMS Press</a>和在主题functions.php文件里添加代码实现该功能，3.0后台并没有可以直接使用的。</p>
<p>比如在functions.php文件里添加如下代码就可以得到一个movie类型的内容：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// 创建叫做“movie”类型的内容 </span>
register_post_type<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'movies'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Movies'</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'capability_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'slug'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'movies'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> 
<span style="color: #0000ff;">'supports'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> 
<span style="color: #0000ff;">'title'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'editor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'excerpt'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'trackbacks'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom-fields'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'revisions'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'author'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'page-attributes'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>这是另一种代码写法，比如创建一个名为“Portfolio（作品集）”的新文章类型：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> post_type_portfolio<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    register_post_type<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Portfolio'</span><span style="color: #339933;">,</span>
                <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Portfolio'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'public'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'show_ui'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    register_taxonomy_for_object_type<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post_tag'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Portfolio'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_type_portfolio'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>添加了代码后就可以在后台找到相应的选项了。</p>
<p><strong>2. 菜单管理</strong></p>
<p>菜单管理应该算是WordPress3.0里最让人津津乐道的一个新功能了。它让你可以完全掌控站点的导航菜单。通过便捷的拖放界面，用户可以自由创建各种组合的链接：内部链接、外部链接、分类等。而且你可以将这些自定义菜单嵌入主题中的任意位置，把它们当成widgets来看待。</p>
<p>我们假设你的站点上有几个信息页面、一个博客、精彩视频同时还要宣传自己的社交媒体账户，那么你可以按下面这样来处理主要导航栏：</p>
<p>主页<br />
博客（链接到博客主页面）<br />
视频 （链接到视频分类或视频类型的内容）<br />
信息页面<br />
信息页面<br />
子信息页面<br />
新浪微博 （链接到新浪微薄账户）<br />
腾讯微博 （链接到腾讯微博页面）</p>
<p>另外，在WordPress3.0中修改这些排序、标题名称、链接目的地也是轻而易举的事情。</p>
<p><strong>3.自定义分类法</strong></p>
<p>对于非开发人员来说，这个新的功能可能有点复杂，不过不管怎么说，它毫无疑问将WordPress3.0向一个真正的内容管理系统又再推进了一步。自定义分类法允许你创建额外的meta信息。默认情况下是有“分类”和“标签”这两种。 现在你可以添加更多的类型，并且可以选择是否需要层级结构。</p>
<p>这到底是什么意思呢？我们来看一下下面的例子：</p>
<p>假设你是一个影迷，使用WordPress博客来发布评论、给新电影评分，那么你就可以创建一个自定义的分类来“评级”给每个评论边加上评分的选项。</p>
<p>另外，对于公布房产之类信息的网站而言，这个功能也显得非常好用。除了图片和描述之外，你可能需要使用额外的分类为每个房产提供一个特定的列表，包括询问价格、房型、建筑年代等。</p>
<p>WordPress3无法在管理后台创建自定义的分类法，使用该功能仍然要拿主题文件夹下的functions.php文件开刀，在该文件里使用build_taxonomies函数来实现。比如创建一个Operating System的分类使用代码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//自定义分类法代码add_action( 'init', 'build_taxonomies', 0 );    </span>
<span style="color: #000000; font-weight: bold;">function</span> build_taxonomies<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>      register_taxonomy
<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'operating_system'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'hierarchical'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span>
 <span style="color: #0000ff;">'Operating System'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'query_var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rewrite'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>关于此函数用法更多信息见这里：http://codex.wordpress.org/Function_Reference/register_taxonomy</p>
<p><strong>4. 新的默认主题： “Twentyten”</strong></p>
<p>Twentyten这个主题也让大家期待已久，这款主题相当简洁但却引入了一些在其他主题中所没有的完美的功能。如果你是WordPress新手，不懂如何利用代码来自定义主题，Twentyten内置的下面这两个功能将会显得更加实用：</p>
<p><strong>自定义标题图片</strong></p>
<p>在Twentyten主题里，你可以轻松地修改站点标题图片。与主题捆绑的有八个非常有趣的图片可供选择，你也可以自己上传图片。这个功能并不局限于Twentyten这个主题，主题开发者也可以激活并在自己的主题里加入此功能。</p>
<p><strong>自定义背景图片</strong></p>
<p>使用Twentyten的另一个好处是你可以上传背景图片。你也可以自己设置一个固定的背景色。同样地，就算是没有任何web开发经验的人都可以轻松地实现这个，无需编辑css，主题开发者也可以激活并在自己的主题中加入此功能。</p>
<p><strong>5. 多站点</strong></p>
<p>提到WordPress 3.0不可能不说说这个新的多站点功能。是这样的，你可以只需一次安装WordPress，就可以管理多个不同站点（不同域名或二级域名）。之前被称为WordPress MU （多用户）的功能现在已经于WordPress3.0的内核结合在一起了。不过，普通用户并不适合启用多站点功能，因为它需要一定的代码知识还需要配置服务器。也就是说，普通用户可能并不会对多站点的功能感兴趣。<br />
那么究竟谁会从WordPress多站点功能中获益呢？要是你在运行一个博客网（如新浪博客）或管理一个包含多个部门的大组织，或者说你的每一个员工都有自己独特设计的博客或甚至是自己域名下的博客，这些情况下，这个多站点的功能应该会非常实用。</p>
<p>要启用3.0的多站点功能，你只需要打开WordPress根目录下的wp-config.php文件， 在文件的任何位置加上以下内容：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_ALLOW_MULTISITE'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>就可以从<strong>工具>网络菜单</strong>中进入多站点管理界面了。</p>
<p><strong>注意</strong></p>
<p>在激活多站点功能之后，不能把WordPress放在独立文件夹中。否则会影响对子站点的查找。<br />
在以下情况下，不能创建多站点：</p>
<ul>
<li>“WordPress地址（URL）”与“网站地址”不同</li>
<li>“WordPress地址”使用的是IP地址（如 127.0.0.1），或端口号不是 &#8216;:80&#8242;, &#8216;:443&#8242;</li>
<li>提示：如果在本地机器上，请用 &#8216;localhost&#8217; 代替&#8217;127.0.0.1&#8242;</li>
</ul>
<p>要使用非子域名，你可以借助WordPress的<a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/" target="_blank">域名绑定插件</a>。</p>
<p><strong>激活多站点网络</strong></p>
<ol>
<li> 首先，备份已有的wp-config.php文件和.htaccess文件</li>
<li> 在/wp-content/下新建一个文件夹并命名为blogs.dir,这个文件夹用来存储其它站点上传的媒体文件，网络服务器需要能够写入这个文件。并且文件的CHOWN和CHMOD权限要和wp-content文件夹一致。</li>
<li>将WordPress提供的代码添加到wp-config.php文件,WordPress会根据你之前的配置动态生成一段代码，将它们添加到wp-config.php文件的WP_ALLOW_MULTISITE下。</li>
<li>替换.htaccess文件,WordPress同样会动态生成一段代码，用这段代码替换原有的.htaccess文件。</li>
<li>全部完成并保存新的wp-config.php文件和.htaccess文件后，点击“返回Dashboard”，刷新页面你会看见左边的菜单区域多出了一个新选项——超级管理员。这就是添加、管理新站点、新用户的地方了，而你原本的WordPress网站，会成为整个多站点网络的主站。</li>
</ol>
<p><em><strong>其他功能</strong></em></p>
<p>下面是WordPress 3.0在小地方的几点改善：</p>
<p><strong>获得短地址 （用自己的域名）</strong></p>
<p>我们都知道短网址还是挺好用的，特别是随着微博客的日益流行。WordPress 2.9就可以使用短网址wp.me URL shortener。WordPress 3.0将这个功能再进一步，你可以依据自己的域名为文章获取一个短网址。这样你就不需要通过其他短网址服务如 bit.ly来完成。由于这样的短网址里包含了自己的域名，微薄里使用时还是可以为自己的品牌宣传。</p>
<p><strong>作者模板</strong></p>
<p>3.0里一个新的功能就是可以让你创建独特的作者模板。这特别适合多作者的博客，你可以为每个作者页面创建不同的样式和布局。<br />
安装过程中选择用户名和密码</p>
<p>WordPress 3.0之前，安装WordPress的话会自动为用户创建一个叫做“admin”的用户名以及自动生成的密码。现在，在安装的时候你就可以自定义用户名和密码，这样就省得以后还去修改。 这无形当中也增加了WordPress安全等级，很多WordPress站点容易遭受攻击都是由于使用最常见的用户名“admin”。</p>
<p>本文内容综合自wordpress啦！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/439.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>博客更改域名地址无需修改数据库的三种方法</title>
		<link>http://www.happyet.org/412.html</link>
		<comments>http://www.happyet.org/412.html#comments</comments>
		<pubDate>Thu, 20 May 2010 02:28:24 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[方法]]></category>
		<category><![CDATA[更换域名]]></category>

		<guid isPermaLink="false">http://www.happyet.org/412.html</guid>
		<description><![CDATA[大家知道，WP博客更改域名地址，在成功导入数据库和转移网站数据库后，还需要修改HOME和SITEURL两个地址。一般大家都是通过修改数据库，其实不用那么麻烦和危险，通过修改配置文件也可以的。
第一种、修改wp-config.php
1、在wp-config.php中，添加以下两行内容：
define(&#8216;WP_HOME&#8217;,'http://www.newdomain.com&#8217;);
define(&#8216;WP_SITEURL&#8217;,'http://www.newdomain.com&#8217;);
www.newdomain.com代表你的新地址
2、登录后台，在 “常规 -> 设置”重新配置新博客地址（HOME）和安装地址（SITEURL），成功后一定记得删除上面添加的内容。
第二种、修改functions.php
functions.php指的是位于当前博客主题目录内，可以自定义一些主题函数。
1、在functions.php中，添加以下两行内容：
update_option(&#8217;siteurl&#8217;,'http://www.newdomain.com&#8217;);
update_option(&#8216;home&#8217;,'http://www.newdomain.com&#8217;);
同样，www.newdomain.com代表你的新地址
2、登录后台，在 “常规 -> 设置”重新配置新博客地址（HOME）和安装地址（SITEURL），成功后一定记得删除上面添加的内容。
第三种、修改wp-config.php（自动更新地址）
1、在wp-config.php中，添加下面一行内容：
define(&#8216;RELOCATE&#8217;,true);
2、登录后台地址，WP将自动更新安装地址（SITEURL），手动修改博客地址（HOME）地址即可，成功后一定记得删除上面添加的内容。
总结
很显然，第三种是最简单的，无需填写新的博客域名地址，最重要的是一定记得删除添加过的内容咯。
本文转自：http://wordpress.org.cn/thread-61872-1-1.html
]]></description>
			<content:encoded><![CDATA[<p>大家知道，WP博客更改域名地址，在成功导入数据库和转移网站数据库后，还需要修改HOME和SITEURL两个地址。一般大家都是通过修改数据库，其实不用那么麻烦和危险，通过修改配置文件也可以的。</p>
<p><strong>第一种、修改wp-config.php</strong></p>
<p>1、在wp-config.php中，添加以下两行内容：<br />
define(&#8216;WP_HOME&#8217;,'http://www.newdomain.com&#8217;);<br />
define(&#8216;WP_SITEURL&#8217;,'http://www.newdomain.com&#8217;);</p>
<p>www.newdomain.com代表你的新地址</p>
<p>2、登录后台，在 “常规 -> 设置”重新配置新博客地址（HOME）和安装地址（SITEURL），<strong>成功后一定记得删除上面添加的内容。</strong></p>
<p><strong>第二种、修改functions.php</strong></p>
<p>functions.php指的是位于当前博客主题目录内，可以自定义一些主题函数。</p>
<p>1、在functions.php中，添加以下两行内容：</p>
<p>update_option(&#8217;siteurl&#8217;,'http://www.newdomain.com&#8217;);<br />
update_option(&#8216;home&#8217;,'http://www.newdomain.com&#8217;);</p>
<p>同样，www.newdomain.com代表你的新地址</p>
<p>2、登录后台，在 “常规 -> 设置”重新配置新博客地址（HOME）和安装地址（SITEURL），<strong>成功后一定记得删除上面添加的内容。</strong></p>
<p><strong>第三种、修改wp-config.php（自动更新地址）</strong></p>
<p>1、在wp-config.php中，添加下面一行内容：<br />
define(&#8216;RELOCATE&#8217;,true);</p>
<p>2、登录后台地址，WP将自动更新安装地址（SITEURL），手动修改博客地址（HOME）地址即可，<strong>成功后一定记得删除上面添加的内容。</strong></p>
<p><strong>总结</strong></p>
<p>很显然，第三种是最简单的，无需填写新的博客域名地址，最重要的是一定记得删除添加过的内容咯。</p>
<p>本文转自：http://wordpress.org.cn/thread-61872-1-1.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/412.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>解决Wordpress的RSS阅读内容无格式的方法</title>
		<link>http://www.happyet.org/411.html</link>
		<comments>http://www.happyet.org/411.html#comments</comments>
		<pubDate>Wed, 19 May 2010 01:02:05 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[feed输出]]></category>
		<category><![CDATA[rss订阅]]></category>
		<category><![CDATA[格式]]></category>

		<guid isPermaLink="false">http://www.happyet.org/411.html</guid>
		<description><![CDATA[我不记得从什么时候开始我的wordpress内容在RSS下阅读时所有内容挤在一起了，我曾一度以为是因为通过feedsky的rss地址订阅导致的这个问题，所以也试过将地址直接改成wordpress自带的订阅地址，可是并没有解决问题。当时想，我这个破博客估计除了我自己给自己订阅外，也没有什么人会通过RSS来阅读了，而我自己又不通过rss阅读，所以最后也就放弃修改的念头。
今天在后台审核评论时，看到Carrie同学专程因为这个问题而提醒我，让我感动的泪流满面。我想她一定是实在受不了我这样乱七八糟的feed内容了才会这样善意的提醒的，我终于明白并不是只有我自己一个人在订阅自己的博客，我终于感觉到了自己罪恶，所以我必须马上把这个问题解决了，才能对得起那些默默无闻订阅我博客的好人们。
搜索关键词“wordpress Feed输出 格式 丢失 错误”，解决问题的方法让我想不到的简单，原来只要在后台进行如下操作就OK了：
【后台>设置>阅读】把“Feed中每篇文章，显示”设置成“全部文字”即可。
设置完后我刷新了一下google reader问题解决，还是有格式的样子看起来惹人喜爱啊！
]]></description>
			<content:encoded><![CDATA[<p>我不记得从什么时候开始我的wordpress内容在RSS下阅读时所有内容挤在一起了，我曾一度以为是因为通过feedsky的rss地址订阅导致的这个问题，所以也试过将地址直接改成wordpress自带的订阅地址，可是并没有解决问题。当时想，我这个破博客估计除了我自己给自己订阅外，也没有什么人会通过RSS来阅读了，而我自己又不通过rss阅读，所以最后也就放弃修改的念头。</p>
<p>今天在后台审核评论时，看到<a href="http://blogs.carrielis.com/" target="_blank">Carrie</a>同学专程因为这个问题而<a href="http://www.happyet.org/410.html#comment-1604">提醒我</a>，让我感动的泪流满面。我想她一定是实在受不了我这样乱七八糟的feed内容了才会这样善意的提醒的，我终于明白并不是只有我自己一个人在订阅自己的博客，我终于感觉到了自己罪恶，所以我必须马上把这个问题解决了，才能对得起那些默默无闻订阅我博客的好人们。</p>
<p>搜索关键词“wordpress Feed输出 格式 丢失 错误”，解决问题的方法让我想不到的简单，原来只要在后台进行如下操作就OK了：</p>
<blockquote><p>【后台>设置>阅读】把“<strong>Feed中每篇文章，显示</strong>”设置成<strong>“全部文字</strong>”即可。</p></blockquote>
<p>设置完后我刷新了一下google reader问题解决，还是有格式的样子看起来惹人喜爱啊！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/411.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Wordpress显示单一分类和分类下文章</title>
		<link>http://www.happyet.org/410.html</link>
		<comments>http://www.happyet.org/410.html#comments</comments>
		<pubDate>Tue, 18 May 2010 01:33:05 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[分类名]]></category>
		<category><![CDATA[分类目录]]></category>
		<category><![CDATA[分类说明]]></category>

		<guid isPermaLink="false">http://www.happyet.org/410.html</guid>
		<description><![CDATA[上周五接了个主题，其中有一个要求在侧边显示默认分类名称和分类下文章标题，搜索了一下马上就找到显示单一分类下文章的写法，于是我自以为是的在循环外加了the_category(&#8216;, &#8216;) ，后来发现这函数在首页时显示正常，可是在其他分类页面下时显示的是该分类的名字，难道是要放循环内？可是放了循环内后发现侧边的排列变成一个标题对应一次分类名，将默认分类下的文章分N次显示了出来。。。
这时候我知道靠猜是解决不了问题了，只能再搜索了。
wordpress的函数真的是n多，就一个分类的函数就不知道有多少种写法，尤其是list_cats()，也写成list_categories()更是随着括号内的参数变化而千变万化，最后才发现原来还有一个叫single_cat_title()的函数，其实我也用过，可是以前根本没有区分的概念，用上它好腰不酸腿不疼了。
具体代码如下：

1
2
3
4
5
6
7
&#60;?php $posts = query_posts&#40;$query_string . &#34;&#38;cat=1&#38;orderby=date&#38;showposts=10&#34; &#41;; ?&#62; 
  &#60;h3&#62;&#60;?php single_cat_title&#40;&#41; ?&#62;&#60;/h3&#62;
    &#60;?php while&#40;have_posts&#40;&#41;&#41; : the_post&#40;&#41;; ?&#62;
      &#60;ul&#62;
        &#60;li&#62;&#60;a href=&#34;&#60;?php the_permalink&#40;&#41; ?&#62;&#34; rel=&#34;bookmark&#34; title=&#34;&#60;?php the_title&#40;&#41;; ?&#62;&#34;&#62;&#60;?php the_title&#40;&#41;; ?&#62;&#60;/a&#62;&#60;/li&#62; 
      &#60;/ul&#62;
&#60;?php endwhile; ?&#62;

搞定！另外还有一个和分类有关的，就是分类说明的函数是：echo(category_description())，也写成echo(category_description(the_category_ID(false)/$category))，括号里的“/”是或者的意思，不是共存的。我不知道加括号里的东西和不加有什么区别，不过这个函数默认输出时带p的，为了便于管理得在function.php文件里加：remove_filter(&#8216;term_description&#8217;,'wpautop&#8217;);
2010.06.18编辑：
上面提到的方法不知道是不是php代码没有闭合，对其他php代码会有影响，会导致一些php判断和某些函数无效，因为本人不懂php，所以无法修改。另外在marslau.com看到另外一种方法，因为没有测试，不知道会不会有同样的问题，代码如下：

1
2
3
4
5
6
7
8
9
&#60;?php [...]]]></description>
			<content:encoded><![CDATA[<p>上周五接了个主题，其中有一个要求在侧边显示默认分类名称和分类下文章标题，搜索了一下马上就找到显示单一分类下文章的写法，于是我自以为是的在循环外加了the_category(&#8216;, &#8216;) ，后来发现这函数在首页时显示正常，可是在其他分类页面下时显示的是该分类的名字，难道是要放循环内？可是放了循环内后发现侧边的排列变成一个标题对应一次分类名，将默认分类下的文章分N次显示了出来。。。</p>
<p>这时候我知道靠猜是解决不了问题了，只能再搜索了。</p>
<p>wordpress的函数真的是n多，就一个分类的函数就不知道有多少种写法，尤其是list_cats()，也写成list_categories()更是随着括号内的参数变化而千变万化，最后才发现原来还有一个叫single_cat_title()的函数，其实我也用过，可是以前根本没有区分的概念，用上它好腰不酸腿不疼了。</p>
<p>具体代码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_string</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;cat=1&amp;orderby=date&amp;showposts=10&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 
  &lt;h3&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> single_cat_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h3&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;ul&gt;
        &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt; 
      &lt;/ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>搞定！另外还有一个和分类有关的，就是分类说明的函数是：echo(category_description())，也写成echo(category_description(the_category_ID(false)/$category))，括号里的“/”是或者的意思，不是共存的。我不知道加括号里的东西和不加有什么区别，不过这个函数默认输出时带p的，为了便于管理得在function.php文件里加：remove_filter(&#8216;term_description&#8217;,'wpautop&#8217;);</p>
<p>2010.06.18编辑：</p>
<p>上面提到的方法不知道是不是php代码没有闭合，对其他php代码会有影响，会导致一些php判断和某些函数无效，因为本人不懂php，所以无法修改。另外在marslau.com看到另外一种方法，因为没有测试，不知道会不会有同样的问题，代码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span> “category<span style="color: #339933;">=</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">&amp;</span>numberposts<span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span>″ <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$posts</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;ul&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> setup_postdata<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;li&gt;
        &lt;a href=”<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>” rel=”bookmark” title=”<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>”&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;
    &lt;/li&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/410.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>改变Widget自定义WordPress侧边栏</title>
		<link>http://www.happyet.org/409.html</link>
		<comments>http://www.happyet.org/409.html#comments</comments>
		<pubDate>Fri, 14 May 2010 08:24:16 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[侧边栏]]></category>

		<guid isPermaLink="false">http://www.happyet.org/409.html</guid>
		<description><![CDATA[其实对超过2栏的wp主题我并不怎么感兴趣，不过毕竟是有这么一个功能在，虽然暂时没用到，也无法记下来当个备忘了。
以默认主题为例，主题中的functions.php文件开头有如下代码：

1
2
3
4
5
6
7
8
if &#40; function_exists&#40;'register_sidebar'&#41; &#41; &#123;
	register_sidebar&#40;array&#40;
		'before_widget' =&#62; '&#60;li id=&#34;%1$s&#34; class=&#34;widget %2$s&#34;&#62;',
		'after_widget' =&#62; '&#60;/li&#62;',
		'before_title' =&#62; '&#60;h2 class=&#34;widgettitle&#34;&#62;',
		'after_title' =&#62; '&#60;/h2&#62;',
	&#41;&#41;;
&#125;

修改上面代码中第2行的register_sidebar(array(…为：

1
2
register_sidebars&#40;2, array&#40;…
// 数字2可以换成你想定义的Widget区域的数目。

保存，然后，打开sidebar.php,找到下面的代码片段：

1
2
3
&#60;?php if &#40; !function_exists&#40;‘dynamic_sidebar’&#41; &#124;&#124; !dynamic_sidebar&#40;&#41; &#41; : ?&#62;
…
&#60;?php endif; ?&#62;//可以换成你想定义的Widget区域的数目。

修改为：

1
2
3
4
5
6
7
8
// 显示第1个Widget组。
&#60;?php if &#40; !function_exists&#40;‘dynamic_sidebar’&#41; &#124;&#124; !dynamic_sidebar&#40;1&#41; &#41; : ?&#62;
…
&#60;?php endif; ?&#62;
// 显示第2个Widget组。
&#60;?php if &#40; !function_exists&#40;‘dynamic_sidebar’&#41; &#124;&#124; !dynamic_sidebar&#40;2&#41; &#41; : ?&#62;
…
&#60;?php endif; ?&#62;

]]></description>
			<content:encoded><![CDATA[<p>其实对超过2栏的wp主题我并不怎么感兴趣，不过毕竟是有这么一个功能在，虽然暂时没用到，也无法记下来当个备忘了。</p>
<p>以默认主题为例，主题中的functions.php文件开头有如下代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'register_sidebar'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	register_sidebar<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'before_widget'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;li id=&quot;%1$s&quot; class=&quot;widget %2$s&quot;&gt;'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'after_widget'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'before_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;h2 class=&quot;widgettitle&quot;&gt;'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'after_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/h2&gt;'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>修改上面代码中第2行的<em>register_sidebar(array(…</em>为：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">register_sidebars<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>…
<span style="color: #666666; font-style: italic;">// 数字2可以换成你想定义的Widget区域的数目。</span></pre></td></tr></table></div>

<p>保存，然后，打开sidebar.php,找到下面的代码片段：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span>‘dynamic_sidebar’<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>dynamic_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
…
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>//可以换成你想定义的Widget区域的数目。</pre></td></tr></table></div>

<p>修改为：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">// 显示第1个Widget组。
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span>‘dynamic_sidebar’<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>dynamic_sidebar<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
…
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
// 显示第2个Widget组。
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span>‘dynamic_sidebar’<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>dynamic_sidebar<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
…
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/409.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WordPress图片插件Thumbnails Anywhere</title>
		<link>http://www.happyet.org/403.html</link>
		<comments>http://www.happyet.org/403.html#comments</comments>
		<pubDate>Fri, 23 Apr 2010 04:17:57 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Thumbnails Anywhere]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[缩略图]]></category>

		<guid isPermaLink="false">http://www.happyet.org/403.html</guid>
		<description><![CDATA[虽然我不喜欢插件，给博客装了插件就像在自己身上装了别人的器官一样，不管生理上有没有排斥反应，心里上不自觉的就会有排斥反应了，可能比喻有点不贴切，可能完全是个人感觉。不过下面这个插件，看功能就让人感觉强大牛B，所以推荐推荐！
插件名称：WordPress缩略图插件 Thumbnails Anywhere  //名字有点长
插件作者：布谷鸟 &#124; 鸟类网 &#124; 分享鸟趣 //没错，就是鸟不是什么程序员
插件功能：

调用日志内容中的图片，显示日志缩略图，缩略图链接指向原日志或者原大图。
首页缩略图：首页每篇日志显示缩略图。
随机缩略图：调用随机日志的缩略图，全站任意位置显示。
最新缩略图：调用最新日志的缩略图，全站任意位置显示。
相关缩略图：调用相关日志的缩略图，用于日志页显示。
最热门缩略图：调用最热门日志的缩略图，用全站任意位置显示。
全排列缩略图：可以将同一篇日志内的图片全部排列在一起显示。
分类缩略图：调用当前分类下的日志缩略图，用于分类页显示；调用指定分类下的日志缩略图，全站任意位置显示。
任意指定缩略图数量、尺寸、距离。
指定显示日志的第一张图片，还是日志内任意图片。
支持侧边栏。
支持根据分类名和标签名排除日志缩略图。
对于站内图片，自动生成缩略图；对于外链图片，自动下载到本地，自动生成缩略图。
对Yupoo、Flickr、Picasa外链图片提供特别支持，可直接引用外链缩略图。

插件下载：Version 2.2.6 下载地址：http://niaolei.org.cn/wp-content/download/thumbnails_anywhere.zip（2010.4.17更新）
插件安装：

如果你是Google Picasa相册用户，在安装之前请先看完这篇文章《Google Picasa图片本地化的方法》；
后台安装，激活；
设置：选项——缩略图；
放置代码或者在后台小工具启用侧边栏；
回到首页点开几篇日志；//这一步不能省略。

插件使用：
1. 首页缩略图

1
&#60;?php if &#40; function_exists&#40;'thumbnails_anywhere_for_homepage'&#41; &#41; &#123;thumbnails_anywhere_for_homepage&#40;&#41;;&#125; ?&#62;

放置位置：于首页模板index.php，放在the_content或the_excerpt之前，
2. 智能首页缩略图：

1
&#60;?php if&#40;function_exists&#40;'thumbnails_anywhere_for_smart_homepage'&#41;&#41; &#123; thumbnails_anywhere_for_smart_homepage&#40;&#41;; &#125; ?&#62;

放置位置：代码放置于首页模板,置于the_content或the_excerpt之后。
功能说明：如果日志内图片很少, 那么调用首页缩略图，否则排列显示该日志内所有缩略图。是上面两种方式的结合
3. 随机缩略图：

1
&#60;?php if&#40;function_exists&#40;'thumbnails_anywhere_for_random_posts'&#41;&#41; &#123; thumbnails_anywhere_for_random_posts&#40;&#41;; &#125; ?&#62;

放置位置：任意位置。（支持侧边栏）
4. 最新缩略图：

1
&#60;?php if&#40;function_exists&#40;'thumbnails_anywhere_for_recent_posts'&#41;&#41; &#123; thumbnails_anywhere_for_recent_posts&#40;&#41;; &#125; ?&#62;

放置位置：任意位置。（支持侧边栏）
5. 相关缩略图：

1
&#60;?php if&#40;function_exists&#40;'thumbnails_anywhere_for_related_posts'&#41;&#41; &#123; thumbnails_anywhere_for_related_posts&#40;&#41;;&#125; ?&#62;

放置位置：日志页模板(single.php)的任意位置。
6. 分类缩略图：

1
&#60;?php if&#40;function_exists&#40;'thumbnails_anywhere_for_category'&#41;&#41; &#123; thumbnails_anywhere_for_category&#40;&#41;; &#125; ?&#62;

放置位置：分类页模板(通常是archive.php)的任意位置。
【注意】：这里的分类缩略图是指将某个分类的图片集中放在一起显示，如果要在分类页实现类似首页缩略图的效果，请仍然使用thumbnails_anywhere_for_homepage的代码。
7. 最热门日志缩略图:
必须先安装统计插件wp-postviews，根据访问数展示缩略图，后台设置非常细致丰富，甚至可以结合标签过滤，隐藏你不想展示的文章。

1
&#60;?php if&#40;function_exists&#40;'thumbnails_anywhere_for_popular_posts'&#41;&#41; &#123; thumbnails_anywhere_for_popular_posts&#40;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>虽然我不喜欢插件，给博客装了插件就像在自己身上装了别人的器官一样，不管生理上有没有排斥反应，心里上不自觉的就会有排斥反应了，可能比喻有点不贴切，可能完全是个人感觉。不过下面这个插件，看功能就让人感觉强大牛B，所以推荐推荐！</p>
<p><strong>插件名称：</strong>WordPress缩略图插件 Thumbnails Anywhere  //名字有点长</p>
<p><strong>插件作者：</strong><a href="http://niaolei.org.cn/" target="_blank">布谷鸟 | 鸟类网 | 分享鸟趣</a> //没错，就是鸟不是什么程序员</p>
<p><strong>插件功能：</strong></p>
<ol>
<li>调用日志内容中的图片，显示日志缩略图，缩略图链接指向原日志或者原大图。</li>
<li>首页缩略图：首页每篇日志显示缩略图。</li>
<li>随机缩略图：调用随机日志的缩略图，全站任意位置显示。</li>
<li>最新缩略图：调用最新日志的缩略图，全站任意位置显示。</li>
<li>相关缩略图：调用相关日志的缩略图，用于日志页显示。</li>
<li>最热门缩略图：调用最热门日志的缩略图，用全站任意位置显示。</li>
<li>全排列缩略图：可以将同一篇日志内的图片全部排列在一起显示。</li>
<li>分类缩略图：调用当前分类下的日志缩略图，用于分类页显示；调用指定分类下的日志缩略图，全站任意位置显示。</li>
<li>任意指定缩略图数量、尺寸、距离。</li>
<li>指定显示日志的第一张图片，还是日志内任意图片。</li>
<li>支持侧边栏。</li>
<li>支持根据分类名和标签名排除日志缩略图。</li>
<li>对于站内图片，自动生成缩略图；对于外链图片，自动下载到本地，自动生成缩略图。</li>
<li>对Yupoo、Flickr、Picasa外链图片提供特别支持，可直接引用外链缩略图。</li>
</ol>
<p><strong>插件下载：</strong>Version 2.2.6 下载地址：<a href="http://niaolei.org.cn/wp-content/download/thumbnails_anywhere.zip">http://niaolei.org.cn/wp-content/download/thumbnails_anywhere.zip</a>（2010.4.17更新）</p>
<p><strong>插件安装：</strong></p>
<ol>
<li>如果你是Google Picasa相册用户，在安装之前请先看完这篇文章《Google Picasa图片本地化的方法》；</li>
<li>后台安装，激活；</li>
<li>设置：选项——缩略图；</li>
<li>放置代码或者在后台小工具启用侧边栏；</li>
<li><strong>回到首页点开几篇日志；//这一步不能省略。</strong></li>
</ol>
<p><strong>插件使用：</strong></p>
<p>1. 首页缩略图</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_homepage'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>thumbnails_anywhere_for_homepage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：于首页模板index.php，放在the_content或the_excerpt之前，</p>
<p>2. 智能首页缩略图：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_smart_homepage'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> thumbnails_anywhere_for_smart_homepage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：代码放置于首页模板,置于the_content或the_excerpt之后。</p>
<p>功能说明：如果日志内图片很少, 那么调用首页缩略图，否则排列显示该日志内所有缩略图。是上面两种方式的结合</p>
<p>3. 随机缩略图：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_random_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> thumbnails_anywhere_for_random_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：任意位置。（支持侧边栏）</p>
<p>4. 最新缩略图：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_recent_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> thumbnails_anywhere_for_recent_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：任意位置。（支持侧边栏）</p>
<p>5. 相关缩略图：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_related_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> thumbnails_anywhere_for_related_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：日志页模板(single.php)的任意位置。</p>
<p>6. 分类缩略图：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_category'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> thumbnails_anywhere_for_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：分类页模板(通常是archive.php)的任意位置。</p>
<p>【注意】：这里的分类缩略图是指将某个分类的图片集中放在一起显示，如果要在分类页实现类似首页缩略图的效果，请仍然使用thumbnails_anywhere_for_homepage的代码。</p>
<p>7. 最热门日志缩略图:</p>
<p>必须先安装统计插件wp-postviews，根据访问数展示缩略图，后台设置非常细致丰富，甚至可以结合标签过滤，隐藏你不想展示的文章。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnails_anywhere_for_popular_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> thumbnails_anywhere_for_popular_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>放置位置：任意位置。</p>
<p>8. 带参数的调用方式：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">随机缩略图：thumbnails_anywhere_for_random_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'num=10&amp;width=100&amp;height=50'</span><span style="color: #009900;">&#41;</span>
最新缩略图：thumbnails_anywhere_for_recent_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'num=20&amp;width=200&amp;height=60'</span><span style="color: #009900;">&#41;</span>
相关缩略图：thumbnails_anywhere_for_related_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'num=30&amp;width=150&amp;height=70'</span><span style="color: #009900;">&#41;</span>
最热门缩略图：thumbnails_anywhere_for_popular_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'num=100&amp;width=180&amp;height=75'</span><span style="color: #009900;">&#41;</span>
全排列缩略图：thumbnails_anywhere_for_single_post<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'num=9&amp;width=75&amp;height=75'</span><span style="color: #009900;">&#41;</span>
分类缩略图：thumbnails_anywhere_for_category<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id=5&amp;width=180&amp;height=75&amp;order=recent'</span><span style="color: #009900;">&#41;</span>
显示分类id为<span style="color: #cc66cc;">5</span>的缩略图，顺序有随机random和最新recent两种，位置任意放置。你甚至可以做一个简单的分类相册。</pre></td></tr></table></div>

<p>（不带参数时，采用后台设置）：依次是数量num、宽度width、高度height。</p>
<p>插件常见问题解答：http://niaolei.org.cn/thumbnails_anywhere/faq</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/403.html/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>自动显示博客版权的方法</title>
		<link>http://www.happyet.org/396.html</link>
		<comments>http://www.happyet.org/396.html#comments</comments>
		<pubDate>Wed, 14 Apr 2010 09:41:39 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[技巧]]></category>
		<category><![CDATA[显示版权]]></category>

		<guid isPermaLink="false">http://www.happyet.org/396.html</guid>
		<description><![CDATA[该方法可以动态地检查你的建博时间，若你的建博时间不满一年，则输出格式为：Copyright © 2009 Happyet.Org
若你的博客建立了超过一年的时间，则输出的格式为：Copyright © 2009-2010 Happyet.Org
在function.php文件中（好可怜，总是往这文件里塞东西！）复制添加下面代码：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function copyrightDate&#40;&#41; &#123;
	global $wpdb;
	$copyright_dates = $wpdb-&#62;get_results&#40;&#34;
		SELECT 
			YEAR(min(post_date_gmt)) AS firstdate, 
			YEAR(max(post_date_gmt)) AS lastdate 
		FROM 
			$wpdb-&#62;posts
	&#34;&#41;;
	if&#40;$copyright_dates&#41; &#123;
		$copyright = &#34;Copyright &#38;copy; &#34; . $copyright_dates&#91;0&#93;-&#62;firstdate;
		if&#40;$copyright_dates&#91;0&#93;-&#62;firstdate != $copyright_dates&#91;0&#93;-&#62;lastdate&#41; &#123;
			$copyright .= '-' . $copyright_dates&#91;0&#93;-&#62;lastdate;
		&#125;
		echo $copyright . &#34;&#38;nbsp;&#34; . get_bloginfo&#40;'name'&#41;;
	&#125;
&#125;
add_filter&#40;'wp_footer', 'copyrightDate'&#41;;

就这样！
from:http://www.ihiro.org/4-ways-to-display-the-copyrights-of-blog
]]></description>
			<content:encoded><![CDATA[<p>该方法可以动态地检查你的建博时间，若你的建博时间不满一年，则输出格式为：Copyright © 2009 Happyet.Org</p>
<p>若你的博客建立了超过一年的时间，则输出的格式为：Copyright © 2009-2010 Happyet.Org</p>
<p>在function.php文件中（好可怜，总是往这文件里塞东西！）复制添加下面代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> copyrightDate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$copyright_dates</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
		SELECT 
			YEAR(min(post_date_gmt)) AS firstdate, 
			YEAR(max(post_date_gmt)) AS lastdate 
		FROM 
			<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>
	&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$copyright_dates</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$copyright</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Copyright &amp;copy; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$copyright_dates</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">firstdate</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$copyright_dates</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">firstdate</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$copyright_dates</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastdate</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$copyright</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$copyright_dates</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">lastdate</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$copyright</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&amp;nbsp;&quot;</span> <span style="color: #339933;">.</span> get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'copyrightDate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>就这样！</p>
<p>from:http://www.ihiro.org/4-ways-to-display-the-copyrights-of-blog</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/396.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress 短代码（简码）收藏</title>
		<link>http://www.happyet.org/394.html</link>
		<comments>http://www.happyet.org/394.html#comments</comments>
		<pubDate>Tue, 13 Apr 2010 03:58:24 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[短代码]]></category>
		<category><![CDATA[简码]]></category>

		<guid isPermaLink="false">http://www.happyet.org/394.html</guid>
		<description><![CDATA[我知道wordpress有神奇的自定义函数，这个自定义函数基本上可以代替大部分的插件了；我也知道wordpress有神奇的自定义域，虽然用起来比较麻烦，但是不能不说它真的很强大；今天我才发现，原来wordpress还有更神奇的短代码（简码）的功能！当然，还是得借助function.php这个文件来实现。
什么是短代码（简码）？就是你在写日志的时候，在编辑器里随便插入几个英文字符，当出现在文章里的时候，它就是千变万化的其他内容了。你说神奇不？！
一、超链接用[url]
1. 打开主题中的functions.php文件。粘贴以下函数到其中：

1
2
3
4
5
6
7
function myUrl&#40;$atts, $content = null&#41; &#123;
extract&#40;shortcode_atts&#40;array&#40;
&#34;href&#34; =&#62; 'http://'
&#41;, $atts&#41;&#41;;
return '&#60;a href=&#34;'.$href.'&#34;&#62;'.$content.'&#60;/a&#62;';
&#125;
add_shortcode&#40;&#34;url&#34;, &#34;myUrl&#34;&#41;;//把函数转化成简码

2. 简码创建成功，现在就可在日志和页面上使用了。
[url href="http://www.wordpress.com"]WordPress recipes[/url]
日志保存后，简码会显示名为“WordPress recipes”的链接，并指向http://www.wordpress.com。
代码注释：若要正常运行，简码必须处理两个参数：$atts 和 $content。$atts是简码属性，上例中，属性为href，且包括了URL链接。$content是简码内容，位于域名和子目录之间（即www.example.com和“/subdirectory”之间）。正如以上显示，我们给$atts 和 $content都设置了默认值。
二、创建“发送到 twitter” 的简码

1
2
3
4
function twitt&#40;&#41; &#123;
return '&#60;div id=&#34;twitit&#34;&#62;&#60;a href=&#34;http://twitter.com/home?status=Currently reading '.get_permalink&#40;$post-&#62;ID&#41;.'&#34; title=&#34;Click to send this page to Twitter!&#34; target=&#34;_blank&#34;&#62;Share on Twitter&#60;/a&#62;&#60;/div&#62;';
&#125;
add_shortcode&#40;'twitter', 'twitt'&#41;;

然后只要在你文章需要的地方插入[twitter]此简码，“发送到Twitter”链接就会只出现放置简码的位置。
三、创建“RSS订阅”简码

1
2
3
4
function subscribeRss&#40;&#41; &#123;
return '&#60;div class=&#34;rss-box&#34;&#62;&#60;a href=&#34;http://feed.happyet.org&#34;&#62;Enjoyed this post? Subscribe to my RSS feeds!&#60;/a&#62;&#60;/div&#62;';
&#125;
add_shortcode&#40;'subscribe', 'subscribeRss'&#41;;

同样用[subscribe]就可以显示了，当然加点css修饰一下就更好了。
四、定制Google AdSense位置

1
2
3
4
5
6
function [...]]]></description>
			<content:encoded><![CDATA[<p>我知道wordpress有神奇的自定义函数，这个自定义函数基本上可以代替大部分的插件了；我也知道wordpress有神奇的自定义域，虽然用起来比较麻烦，但是不能不说它真的很强大；今天我才发现，原来wordpress还有更神奇的短代码（简码）的功能！当然，还是得借助function.php这个文件来实现。</p>
<p>什么是短代码（简码）？就是你在写日志的时候，在编辑器里随便插入几个英文字符，当出现在文章里的时候，它就是千变万化的其他内容了。你说神奇不？！</p>
<p><strong>一、超链接用[url]</strong></p>
<p>1. 打开主题中的functions.php文件。粘贴以下函数到其中：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> myUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;href&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$href</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$content</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;url&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;myUrl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//把函数转化成简码</span></pre></td></tr></table></div>

<p>2. 简码创建成功，现在就可在日志和页面上使用了。</p>
<p>[url href="http://www.wordpress.com"]WordPress recipes[/url]</p>
<p>日志保存后，简码会显示名为“WordPress recipes”的链接，并指向http://www.wordpress.com。</p>
<p>代码注释：若要正常运行，简码必须处理两个参数：$atts 和 $content。$atts是简码属性，上例中，属性为href，且包括了URL链接。$content是简码内容，位于域名和子目录之间（即www.example.com和“/subdirectory”之间）。正如以上显示，我们给$atts 和 $content都设置了默认值。</p>
<p><strong>二、创建“发送到 twitter” 的简码</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> twitt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div id=&quot;twitit&quot;&gt;&lt;a href=&quot;http://twitter.com/home?status=Currently reading '</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; title=&quot;Click to send this page to Twitter!&quot; target=&quot;_blank&quot;&gt;Share on Twitter&lt;/a&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'twitter'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'twitt'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>然后只要在你文章需要的地方插入[twitter]此简码，“发送到Twitter”链接就会只出现放置简码的位置。</p>
<p><strong>三、创建“RSS订阅”简码</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> subscribeRss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div class=&quot;rss-box&quot;&gt;&lt;a href=&quot;http://feed.happyet.org&quot;&gt;Enjoyed this post? Subscribe to my RSS feeds!&lt;/a&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'subscribe'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'subscribeRss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>同样用[subscribe]就可以显示了，当然加点css修饰一下就更好了。</p>
<p><strong>四、定制Google AdSense位置</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> showads<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div id=&quot;adsense&quot;&gt;
//google adsense code here
&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adsense'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'showads'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>使用[adsense]在你需要的位置调用google ad，记得给外包的那个div设置css样式。</p>
<p><strong>五、嵌入RSS阅读器</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//This file is needed to be able to use the wp_rss() function.</span>
<span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span>ABSPATH<span style="color: #339933;">.</span>WPINC<span style="color: #339933;">.</span><span style="color: #0000ff;">'/rss.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> readRss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;feed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> wp_rss<span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'readRss'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;;</span></pre></td></tr></table></div>

<p>使用简码的时候输入：[rss feed="http://feed.happyet.org" num="5"]<br />
feed属性（attribute）即是要嵌入的feed URL，num即是要显示的条目数量。</p>
<p><strong>六、使用简码从WordPress数据库中提取文章</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sc_liste<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;num&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'5'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;cat&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myposts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts='</span><span style="color: #339933;">.</span><span style="color: #000088;">$num</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;order=DESC&amp;orderby=post_date&amp;category='</span><span style="color: #339933;">.</span><span style="color: #000088;">$cat</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$retour</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myposts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$retour</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span>the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$retour</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">'&lt;/ul&gt; '</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$retour</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;list&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sc_liste&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>在WordPress编辑器中使用以下简码：[liste num="3" cat="1"]，系统将从ID为1的类别中提取3篇文章。</p>
<p>代码注释：系统提取参数并创建全局变量$posts后，sc_liste()函数使用了 get_posts()，numberposts, order, orderby和category参数以从类别Y中获取X篇最新日志。完成后，系统就会以无序的HTML列表形式显示日志。</p>
<p><strong>七、获取日志中的最新图像</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sc_postimage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">&quot;size&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">&quot;float&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'none'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$images</span> <span style="color: #339933;">=&amp;</span> get_children<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'post_type=attachment&amp;post_mime_type=image&amp;post_parent='</span> <span style="color: #339933;">.</span> get_the_id<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$images</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$imageID</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$imagePost</span> <span style="color: #009900;">&#41;</span>
<span style="color: #000088;">$fullimage</span> <span style="color: #339933;">=</span> wp_get_attachment_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$size</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imagedata</span> <span style="color: #339933;">=</span> wp_get_attachment_image_src<span style="color: #009900;">&#40;</span><span style="color: #000088;">$imageID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$size</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$width</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagedata</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$height</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$imagedata</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div class=&quot;postimage&quot; style=&quot;width: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$width</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'px; height: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$height</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'px; float: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$float</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$fullimage</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;postimage&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sc_postimage&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>使用代码：[postimage size="" float="left"]</p>
<p>代码注释：sc_postimage()函数首先提取了简码属性，然后它使用get_children(), wp_get_attachment_image() 和wp_get_attachment_image_src()这些WordPress函数检索图像。完成后，系统就会返回图像并插入到文章内容中。</p>
<p><strong>八、在侧边栏微件中添加简码</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_text'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'do_shortcode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>好是好，function.php文件得爆炸了。。。不知道会不会对速度有影响。</p>
<p>from:http://mcooo.com/wordpress-favorites.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/394.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>wp主题切换功能</title>
		<link>http://www.happyet.org/392.html</link>
		<comments>http://www.happyet.org/392.html#comments</comments>
		<pubDate>Mon, 05 Apr 2010 06:21:44 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[word]]></category>
		<category><![CDATA[主题切换]]></category>

		<guid isPermaLink="false">http://www.happyet.org/392.html</guid>
		<description><![CDATA[以前在willin大师那看到过，可以自由切换主题的，现在换了主题后没有了。这周末在看《锋利的jQuery》的时候，看到里面提到这个功能，我就一样画葫芦，完全照搬代码的弄了一个，居然被我弄成功了。而且通过那个cookie的js可以保证下次登录的时候还是你选择的那个主题，唯一遗憾的是切换主题后，刷新时会有一小会的闪烁下默认主题。因为是菜鸟，不知道如何解决。有知道的可以给我指点指点啊！
代码都在《锋利的jQuery》书里第五章和第七章，就不打了，pdf格式的书在木木同学博客上有下载，搜索一下就好了。
效果见：http://lms.im
黑白两色的主题，效果图：


在玩浏览器的时候发现一个浏览器很牛逼，就是下图最右边形成一条竖线的那个，猜猜是什么浏览器！

]]></description>
			<content:encoded><![CDATA[<p>以前在<a href="http://willin.heliohost.org/" targent="_blank">willin大师</a>那看到过，可以自由切换主题的，现在换了主题后没有了。这周末在看《锋利的jQuery》的时候，看到里面提到这个功能，我就一样画葫芦，完全照搬代码的弄了一个，居然被我弄成功了。而且通过那个cookie的js可以保证下次登录的时候还是你选择的那个主题，唯一遗憾的是切换主题后，刷新时会有一小会的闪烁下默认主题。因为是菜鸟，不知道如何解决。有知道的可以给我指点指点啊！</p>
<p>代码都在《锋利的jQuery》书里第五章和第七章，就不打了，pdf格式的书在<a href="http://immmmm.com" targent="_blank">木木同学</a>博客上有下载，搜索一下就好了。</p>
<p>效果见：<a href="http://lms.im" targent="_blank">http://lms.im</a></p>
<p>黑白两色的主题，效果图：</p>
<p><img src="http://www.happyet.org/wp-content/uploads/2010/04/xiaohei.JPG" class="aligncenter" width=400px /><br />
<img src="http://www.happyet.org/wp-content/uploads/2010/04/xiaobai.JPG" class="aligncenter" width=400px /></p>
<p>在玩浏览器的时候发现一个浏览器很牛逼，就是下图最右边形成一条竖线的那个，猜猜是什么浏览器！</p>
<p><img src="http://www.happyet.org/wp-content/uploads/2010/04/liulanqi.JPG" class="aligncenter"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/392.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>无插件实现 wordpress 彩色标签云效果</title>
		<link>http://www.happyet.org/391.html</link>
		<comments>http://www.happyet.org/391.html#comments</comments>
		<pubDate>Thu, 01 Apr 2010 06:35:04 +0000</pubDate>
		<dc:creator>LMS</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[彩色标签]]></category>

		<guid isPermaLink="false">http://www.happyet.org/391.html</guid>
		<description><![CDATA[一、随机颜色
将以下代码放入主题包 functions.php 文件内：

1
2
3
4
5
6
7
8
9
10
11
12
function colorCloud&#40;$text&#41; &#123; 
$text = preg_replace_callback&#40;'&#124;&#60;a (.+?)&#62;&#124;i', 'colorCloudCallback', $text&#41;;
return $text;
&#125; 
function colorCloudCallback&#40;$matches&#41; &#123; 
$text = $matches&#91;1&#93;;
$color = dechex&#40;rand&#40;0,16777215&#41;&#41;;
$pattern = '/style=(\'&#124;\&#34;)(.*)(\'&#124;\&#34;)/i';
$text = preg_replace&#40;$pattern, &#34;style=\&#34;color:#{$color};$2;\&#34;&#34;, $text&#41;;
return &#34;&#60;a $text&#62;&#34;;
&#125; 
add_filter&#40;'wp_tag_cloud', 'colorCloud', 1&#41;;

第8行代码”$color=dechex(rand(0,16777215));”：作用是定义标签随机颜色的十进制数值范围，0 等于 #000000，16777215 等于 #ffffff。你可以使用进制换算工具换算后修改这行代码，改变颜色范围。
在主题需要的地方加入以下代码：

1
&#60;?php wp_tag_cloud&#40;'smallest=8&#38;largest=24&#38;number=50'&#41;; ?&#62;

代码说明：

“smallest”：最小的字体尺寸（使用频率最少的标签）
“largest”：最大的字体尺寸（频率最多的）
“number”：则表示标签显示数量。

KO！
from:http://hezi.info/share/wordpress/wordpress-colore-tag.html
二、自定义颜色

1
2
3
4
5
6
7
8
9
10
11
function colorCloudCallback&#40;$matches&#41; &#123;
$tag_link=$matches&#91;1&#93;;
/*颜色集合*/
$colorFull = array&#40;‘#999′,’#D8D9A4′,’#9BB’,'#EB9′,’#a3c159′,’#FEC42D’,'#6C8C37′,
‘#c2dc15′,’#3371A3′,’#888′,’#00ccff’,'#FF8080′);
$color=$colorFull&#91; mt_rand&#40;0, count&#40;$colorFull&#41; - 1&#41;&#93;;
$pattern = ‘/style=&#40;\’&#124;\”&#41;&#40;.*&#41;&#40;\’&#124;\”&#41;/i’;
$tag_link= preg_replace&#40;$pattern, “style=\”color:&#123;$color&#125;;$2;\”&#34;, $tag_link);
return “&#60;a $tag_link&#62;”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);

from:http://mcooo.com/
]]></description>
			<content:encoded><![CDATA[<p><strong>一、随机颜色</strong></p>
<p>将以下代码放入主题包 functions.php 文件内：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> colorCloud<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace_callback</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|&lt;a (.+?)&gt;|i'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'colorCloudCallback'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">function</span> colorCloudCallback<span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$color</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dechex</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">16777215</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/style=(\'|\&quot;)(.*)(\'|\&quot;)/i'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;style=<span style="color: #000099; font-weight: bold;">\&quot;</span>color:#<span style="color: #006699; font-weight: bold;">{$color}</span>;<span style="color: #006699; font-weight: bold;">$2</span>;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;&lt;a <span style="color: #006699; font-weight: bold;">$text</span>&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_tag_cloud'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'colorCloud'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>第8行代码”<strong>$color=dechex(rand(0,16777215));</strong>”：作用是定义标签随机颜色的十进制数值范围，0 等于 #000000，16777215 等于 #ffffff。你可以使用进制换算工具换算后修改这行代码，改变颜色范围。</p>
<p>在主题需要的地方加入以下代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_tag_cloud<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'smallest=8&amp;largest=24&amp;number=50'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>代码说明：</strong></p>
<ul>
<li>“smallest”：最小的字体尺寸（使用频率最少的标签）</li>
<li>“largest”：最大的字体尺寸（频率最多的）</li>
<li>“number”：则表示标签显示数量。</li>
</ul>
<p>KO！</p>
<p>from:http://hezi.info/share/wordpress/wordpress-colore-tag.html</p>
<p><strong>二、自定义颜色</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> colorCloudCallback<span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$tag_link</span><span style="color: #339933;">=</span><span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*颜色集合*/</span>
<span style="color: #000088;">$colorFull</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>‘<span style="color: #666666; font-style: italic;">#999′,’#D8D9A4′,’#9BB’,'#EB9′,’#a3c159′,’#FEC42D’,'#6C8C37′,
</span>‘<span style="color: #666666; font-style: italic;">#c2dc15′,’#3371A3′,’#888′,’#00ccff’,'#FF8080′);
</span><span style="color: #000088;">$color</span><span style="color: #339933;">=</span><span style="color: #000088;">$colorFull</span><span style="color: #009900;">&#91;</span> <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$colorFull</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> ‘<span style="color: #339933;">/</span>style<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>\’<span style="color: #339933;">|</span>\”<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>\’<span style="color: #339933;">|</span>\”<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>i’<span style="color: #339933;">;</span>
<span style="color: #000088;">$tag_link</span><span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> “style<span style="color: #339933;">=</span>\”color<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #000088;">$color</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>$<span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>\”<span style="color: #0000ff;">&quot;, <span style="color: #006699; font-weight: bold;">$tag_link</span>);
return “&lt;a <span style="color: #006699; font-weight: bold;">$tag_link</span>&gt;”;
}
add_filter(‘wp_tag_cloud’, ‘colorCloud’, 1);</span></pre></td></tr></table></div>

<p>from:http://mcooo.com/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.happyet.org/391.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
