WORDPRESS plugin development and learning (1) hello world, wordpresshello
The first article in the WORDPRESS plugin development and learning series adds a fixed character "Hello World" to the end of each article"
1. Open the wordpress directory-> wp-content-> plugins
2. Create a directory 1100w-hello-world under plugins
3. Create two files under 1100w-hello-world
1100w-hello-world.php plug-in file, plug-in entry file. Main function code of plug-in placement. If the plug-in contains many functions, you can place the function code in different php pages. In this example, the function code is fat to the Code 1100w-hello-world.php because only hello world is displayed.
Readme.txt if you want to share the plug-in to the wordpress community, you need to use this file. During the test, the creation is not used.
After the directory is created, the directory structure is as follows:
4. Edit the 1100w-hello-word.php file and enter the following code:
<? Php/* Plugin Name: Hello-WorldPlugin URI: http://110020.com/description: the simplest plug-in implementation, append hello worldVersion: 1.0 Author: 1100 wAuthor URI: http://1100w.comLicense after each article: GPL */?>
After saving the code, open wordpress and go to the background plug-in management. Although no functional code is added, you can see the plug-in information we developed.
The above annotation code is the description code of the wordpress plug-in. The format is fixed and each wordpress plug-in must comply with it. Corresponding:
Plug-in name
Official link of the plug-in
Plug-in description
Version
Author
Author's official link
Open source Protocol
5. Add function code in 1100w-hello-word.php
// Add a filter. When the_content is displayed, execute the hello_world function and append the returned data add_filter ('the _ content', 'Hello _ World '); // callback function hello_world ($ content) {// checks whether the page is single. if (is_single () {// Add Hello World. return $ content. "
6. Activate the plug-in and open a link. The plug-in function is shown as follows: