{"id":641,"date":"2012-06-17T13:26:26","date_gmt":"2012-06-17T05:26:26","guid":{"rendered":"http:\/\/www.dogeye.net\/?p=641"},"modified":"2012-06-17T13:26:26","modified_gmt":"2012-06-17T05:26:26","slug":"a-easy-way-to-add-copyright-information-automatically-into-post","status":"publish","type":"post","link":"https:\/\/ykyi.net\/?p=641","title":{"rendered":"A easy way to add copyright information automatically into post(English Version\u82f1\u6587\u7248)"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p style=\"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); \"><span style=\"line-height: 1.3em; \">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 &quot;add post URL&quot; 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: &quot;<\/span><span style=\"line-height: 1.3em; font-family: arial, helvetica, sans-serif; \"><span style=\"line-height: 16px; \"><span style=\"background-color: rgb(255, 240, 245); \">This plugin has&nbsp;<\/span><\/span><strong style=\"color: rgb(51, 51, 51); font-family: sans-serif; line-height: 16px; background-color: rgb(255, 255, 224); \"><span style=\"background-color: rgb(255, 240, 245); \">not been tested<\/span><\/strong><span style=\"line-height: 16px; \"><span style=\"background-color: rgb(255, 240, 245); \">&nbsp;with your current version of WordPress&quot;. 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.<\/span><\/span><\/span><\/p>\n<p style=\"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); \">&nbsp;<\/p>\n<p style=\"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); \">Then, I tried to modify wordpress&#39;s sourcecode by myself. I googled some related post taking about how to do this kind of work. One article suggested to modify the single.php file, which I am not very sure if the file name will change depends on different themes you use. I reckon the file name will be like the style of &quot;single.php&quot;, more or less. Now, you locate the following code in single.php.<\/p>\n<p style=\"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); \">&nbsp;<\/p>\n<p style=\"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); \">&lt;?php the_content(); ?&gt;<\/p>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&lt;!&#8211;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">Pagination for Multi-page posts<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">~~~ &#8211;&gt;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&lt;?php wp_link_pages(&#39;before=&lt;p class=&quot;multi-page&quot;&gt;Pages:&amp;after=&lt;\/p&gt;&#39;); \/\/ if this is a multipage post then show the navigation ?&gt;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">As long as you&#39;ve found it, insert code that generate copyright information below the line&nbsp;&lt;?php the_content(); ?&gt;. Unfortunately, many people will soon find this is not going to work. Since many other plugins has already add texts into the post content. Take my blog for example, I use the plugin to automatically generate related posts list at the bottom of every post. So, in this way, copyright information will be put right below the related posts list, rather than expected right below the real post content. It is definitely undesirable.&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">I did google more and found a solution. One article suggest to modify function.php and add a customer defined function to replace the original the_content() function in the single.php file. I read the code and found it&#39;s not easy to comprehend for a normal person who are not familiar with wordpress&#39;s code. I didn&#39;t understand the parameters transferred to the function at least. What is more, I greatly doubted this kind of solution will collide with my plugin generating related posts list.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">Everything seemed to get stuck. I went out to have my supper and have some kind of fresh air. When I returned to the front of the computer. I suddenly figured out a perfect solution of add copyright info into my post without using plugin and heavy code. The idea is described as the following steps:<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">step 1: when you are composing your article, type some kind of special and simple string in the place where you expect to show up the copyright information. Take my blog for exambple, I type &quot;COPYRIGHT &nbsp; WWW.DOGEYE.NET&quot; at the tail of every post.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">step 2: Using php code to replace the special string to anything relatively verbose in the time when the post will be showing.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">Isn&#39;t it a brilliant, simple and flexible idea.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">To put this idea into real. You must make it clear that the two function the_content() and get_the_content() behaves differently. When the function the_content() is invoked, the content of the post is being printed out. get_the_content() is different, this function return the article text as a string return value. As you have got this point clear, you should comprehend the following code, which replace the the_content() function with get_the_content() function.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-family: Verdana, Geneva, sans-serif; vertical-align: baseline; color: rgb(0, 0, 0); line-height: 18px; \">\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">&lt;?php<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">$thread_content = get_the_content(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ variable $thread_content holds the post content.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">$thread_permalink = get_permalink(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\/\/ get the current post&#39;s permanent link.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">$thread_title = get_the_title(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ get the current post&#39;s title.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">$dogeye_copyright = &quot;&lt;p style=&#39;font-weight:bold&#39;;&gt;&lt;span&gt;Original Article created by&lt;\/span&gt; &lt;a href=&#39;http:\/\/ykyi.net&#39; target=&#39;_blank&#39;&gt;DogEye.NET&lt;\/a&gt;&lt;br\/&gt;&lt;span&gt;Repost is only allowed if original URL is reserved.&lt;\/span&gt;&lt;br\/&gt;&lt;a href=\\&quot;$thread_permalink\\&quot; target=&#39;_blank&#39;&gt;$thread_title&lt;br\/&gt;$thread_permalink&lt;\/a&gt;&lt;\/p&gt;&quot;; &nbsp;<span style=\"font-family: inherit; font-style: inherit; \">&nbsp;<\/span><span style=\"font-family: inherit; font-style: inherit; \">&nbsp; &nbsp; \/\/ the HTML code that claiming copyright<\/span><\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">\/\/ The following code change the simple string &quot;COPYRIGHT &nbsp;WWW.DOGEYE.NET&quot; with more verbose HTML code.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">$thread_content = str_replace(&#39;COPYRIGHT &nbsp;WWW.DOGEYE.NET&#39;, $dogeye_copyright, $thread_content);<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">echo $thread_content; &nbsp; &nbsp;\/\/ print out the modified content.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">?&gt;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">I suppose this piece of code snippet is easy to comprehend with comments. If you think it is useful, you could replace the site-specified string with your version. Hope this post will be helpful.<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">&nbsp;<\/div>\n<div style=\"margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline; \">COPYRIGHT WWW.DOGEYE.NET<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 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 &hellip; <a href=\"https:\/\/ykyi.net\/?p=641\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A easy way to add copyright information automatically into post(English Version\u82f1\u6587\u7248)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[87],"class_list":["post-641","post","type-post","status-publish","format-standard","hentry","category-tech_articles","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=641"}],"version-history":[{"count":0,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/641\/revisions"}],"wp:attachment":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}