<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Wordpress on kamuszhou&#39;s blog</title>
    <link>https://ykyi.net/tags/wordpress/</link>
    <description>Recent content in Wordpress on kamuszhou&#39;s blog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sun, 17 Jun 2012 05:26:26 +0000</lastBuildDate>
    <atom:link href="https://ykyi.net/tags/wordpress/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>A easy way to add copyright information automatically into post(English Version英文版)</title>
      <link>https://ykyi.net/?p=641/</link>
      <pubDate>Sun, 17 Jun 2012 05:26:26 +0000</pubDate>
      <guid>https://ykyi.net/?p=641/</guid>
      <description>&lt;p&gt; &lt;/p&gt;
&lt;p style=&#34;margin: 0px 0px 0.8em; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; line-height: 1.3em; color: rgb(0, 0, 0); &#34;&gt;
  &lt;span style=&#34;line-height: 1.3em; &#34;&gt;Several weeks ago, I decided to write about two blog posts every day. I used to write copyright information manually in the post. Apparently, it&#39;s better to let the machine do this type of trivial work automatically. So, I searched the plugins to try to find a convenient one. Indeed, I found the plugin named &#34;add post URL&#34; which is able to help the author to insert copyright information into the post. When I clicked the &#39;DETAIL&#39; button to see more. A warning message popped up: &#34;&lt;/span&gt;&lt;span style=&#34;line-height: 1.3em; font-family: arial, helvetica, sans-serif; &#34;&gt;&lt;span style=&#34;line-height: 16px; &#34;&gt;&lt;span style=&#34;background-color: rgb(255, 240, 245); &#34;&gt;This plugin has&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;strong style=&#34;color: rgb(51, 51, 51); font-family: sans-serif; line-height: 16px; background-color: rgb(255, 255, 224); &#34;&gt;&lt;span style=&#34;background-color: rgb(255, 240, 245); &#34;&gt;not been tested&lt;/span&gt;&lt;/strong&gt;&lt;span style=&#34;line-height: 16px; &#34;&gt;&lt;span style=&#34;background-color: rgb(255, 240, 245); &#34;&gt;&amp;nbsp;with your current version of WordPress&#34;. I was scared. Because I once had a bad experience about how untested plugin ruined my wordpress as a whole. So, the option of using plugin to insert copyright information was ruled out.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;</description>
    </item>
    <item>
      <title>一个更方便的在wordpress博客的文章中自动添加版权信息的方法(Chinese Version 中文版)</title>
      <link>https://ykyi.net/?p=628/</link>
      <pubDate>Fri, 15 Jun 2012 13:17:18 +0000</pubDate>
      <guid>https://ykyi.net/?p=628/</guid>
      <description>&lt;p&gt;从半个月前，我决定每天都写两篇左右篇客，或者原创，或者翻译。对于国内的抄袭风气，大家都很清楚，转载别人的文章时把别人的版权信息改成自己的。虽然没有非常好的办法对付抄袭。但至少也需要摆明原创作者的态度还是很必要的。&lt;/p&gt;
&lt;p&gt;一开始，我在每篇博文里手动添加版权信息和链接。虽然工作量不算太大，但对于这种高度重复性的工作，能让机器做还是交给机器做吧。&lt;/p&gt;
&lt;p&gt;首先当然想到的是找相关自动插入版权信息的wordpress插件，虽然也找到一款。名字叫add post，如果没有记错的话！点击Detail查看详细说明的时候发现已经很久没有更新了，而且有一个警告说对于我当前使用的wordpress版本没有经过测试。没有经过测试这句话吓到我了，我不想因为一个插件给我的博客引用不稳定性。于是放弃了使用插件。&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;不能使用插件那就只能自己改代码。谷歌了一下，自然搜索到前人写的相关贴子。贴子介绍说找到single.php文件。single.php文件是发贴发贴的文件，我不确定是不是文件名和所有的主题相关，会不会因为使用不同的主题，这个文件名会不太一样。然后找到这段代码：&lt;/p&gt;
&lt;?php the_content(); ?&gt;
&lt;div&gt;
  &lt;!&amp;#8211;
&lt;/div&gt;
&lt;div&gt;
  Pagination for Multi-page posts
&lt;/div&gt;
&lt;div&gt;
  ~~~ &amp;#8211;&gt;
&lt;/div&gt;
&lt;div&gt;
  &lt;?php wp_link_pages(&#39;before=&lt;p class=&#34;multi-page&#34;&gt;Pages:&amp;after=&lt;/p&gt;&#39;); // if this is a multipage post then show the navigation ?&gt;
&lt;/div&gt;
&lt;div&gt;
  &amp;nbsp;
&lt;/div&gt;
&lt;div&gt;
  然后在这段代码的&lt;?php the_content(); ?&gt; 下面插入生成版本信息的代码。但问题是，这种方法并不可靠。非常多的博客使用了其它相关的插件会干扰这种做法。比如，我使用了一个自动生成相关文章列表的插件。于是版本信息被加到了相关文章列表下面，离真正的文章正文有很远的距离。这必不令人满意。另有文章指出可以修改function.php文件，自定义一个和the_content()类似的函数，然后把single.php中的the_content()函数替换掉来完成这个任务。我看了一下，不太满意。修改的地方超过了两个文件，觉得改动有点多。另外写的那个自定义函数对于没有太多wordpress的代码经验的人来讲并不是非常容易读懂。至少我就不明白那个自定义函数的参数的意义，应该和wordpress的标准代码相关。另外，我很怀疑如果用了这种方式，可以会使我的显示相关博文列表的插件失效。一下子没有找到非常好的解决方法。于是去吃晚饭。吃完晚饭后回到电脑前突然来了灵感。可以在用替换字符串的方法增加版权信息呀。想法是这样的。
&lt;/div&gt;
&lt;div&gt;
  1. 在编辑文章的时候，在你需要插入版本信息的地方加入特殊的字符串。比如我选择了在每篇博文最后敲入字符串 &amp;ldquo;copyright &amp;nbsp;ykyi.net&amp;rdquo;
&lt;/div&gt;
&lt;div&gt;
  2. 在发表文章阶段把这个特殊字符串替换成html代码，显示你的版本信息。
&lt;/div&gt;
&lt;div&gt;
  是不是既简单又灵活呢！
&lt;/div&gt;
&lt;div&gt;
  注意要实现这个想法，需要明白 the_content() 和 get_the_content() 两个wordpress函数的区别。在调用the_content()函数的时候，文章的内容就已经打印出来了。但get_the_content()是把文章的内容做为函数返回值返回。所以在修改single.php文件时，要把 the_content()用get_the_content()函数代替。
&lt;/div&gt;
&lt;div&gt;
  下面贴出我的代码。看官如果需要可以修改相应部分：
&lt;/div&gt;
&lt;div&gt;
  &lt;div&gt;
    &lt;?php
  &lt;/div&gt;
  &lt;div&gt;
    $thread_content = get_the_content();&amp;nbsp;
  &lt;/div&gt;
  &lt;div&gt;
    $thread_permalink = get_permalink();
  &lt;/div&gt;
  &lt;div&gt;
    $thread_title = get_the_title($post_id);
  &lt;/div&gt;
  &lt;div&gt;
    $dogeye_copyright = &#34;&lt;pre&gt;除非明确声明，本站所以文章均为&lt;a href=&#39;http://ykyi.net&#39; target=&#39;_blank&#39;&gt;DogEye博客&lt;/a&gt;原创或者自主翻译。&lt;br/&gt;如转载，请注明出处。&lt;a href=\&#34;$thread_permalink\&#34; target=&#39;_blank&#39;&gt;$thread_title $thread_permalink&lt;/a&gt;&lt;/pre&gt;&#34;;
  &lt;/div&gt;
  &lt;div&gt;
    $thread_content = str_replace(&#39;copyright &amp;nbsp;ykyi.net&#39;, $dogeye_copyright, $thread_content);
  &lt;/div&gt;
  &lt;div&gt;
    echo $thread_content;
  &lt;/div&gt;
  &lt;div&gt;
    ?&gt;
  &lt;/div&gt;
  &lt;div&gt;
    &amp;nbsp;
  &lt;/div&gt;
  &lt;div&gt;
    代码应该非常容易读懂了。而且你可以非常灵活地控制要插入的位置，还可以灵活决定插入多处版本声明。
  &lt;/div&gt;
  &lt;div&gt;
    &amp;nbsp;
  &lt;/div&gt;
  &lt;div&gt;
    copyright ykyi.net
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;</description>
    </item>
  </channel>
</rss>
