The previous article mentioned how to create a plug-in. I think you will surely get some results after reading it. This article briefly gives you a plug-in sample, which gives you a Basic impression. The example of this plug-in is that after you activate this plug-in, you will insert a piece of content you have defined in each article, for example, you want to insert copyright information, subscription information, and so on, the following describes how to add copyright information to the end of each article. The following code is used:
<? PHP/*** @ package add copyright information * @ version 1.0 * // * plugin name: Add copyright information plugin URI: http: // www. add copyright information. comdescription: this is a simple plug-in example. After each article is defined, Author: mynameversion: 1.0 author URI: http://www.cnblogs.com/fxmbz#/add_action ('the _ content ', 'Add _ copyright_info '); function add_copyright_info ($ content) {$ content. = '<Div style = "clear: Both; border-top: 1px dashed # e0e0e0; padding: 10px 0 10px 0; font-size: 12px;"> All Rights Reserved©The author and original source must be indicated in the form of a link: <a href = "'. get_bloginfo ("home "). '"Title =" click to home "> '. get_bloginfo ("name "). '</a>» <a Title = "address of this Article" href = "'. get_permalink (). '"> '. get_the_title (). '</a> </div>'; return $ content ;}?>
Create a file in the folder where the plug-in is located (WP-content/plugins/), such as add_copyright.php, and put the above Code into the file. Refresh the WordPress background and click the plug-in menu to check whether the plug-in name exists. If the plug-in name is activated, the defined information is displayed at the end of each article. This is a very simple plug-in. Some may ask if such a simple method also needs to be implemented as a plug-in? Yes, if you
Add_action ('the _ content', 'add _ copyright_info '); function add_copyright_info ($ content) {$ content. = '<Div style = "clear: Both; border-top: 1px dashed # e0e0e0; padding: 10px 0 10px 0; font-size: 12px;"> All Rights Reserved©The author and original source must be indicated in the form of a link: <a href = "'. get_bloginfo ("home "). '"Title =" click to home "> '. get_bloginfo ("name "). '</a>» <a Title = "address of this Article" href = "'. get_permalink (). '"> '. get_the_title (). '</a> </div>'; return $ content ;}
Code can also work directly in the functions. php file of the topic, which reduces the number of times the plug-in is used. If you are interested, try it.
Using this simple example, creating a plug-in is not as difficult as you think, but you need to have a good PHP Foundation and browse the plug-in documents on the official website. In future articles, I will introduce the commonly used functions of these plug-ins. To provide better help.
WordPress plugin creation tutorial (2): compile a simple plugin