WORDPRESS Plugin Development and Learning (1) HELLOWORLD and wordpresshello. Development and Learning of WORDPRESS plug-ins (I) HELLOWORLD, wordpresshelloWORDPRESS plug-in development and learning first article series, adding a fixed character HelloWorld 1 to the end of each article. open the w WORDPRESS plug-in for 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:
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. "Hello World";} else {// if it is another page, it will not be processed. Return $ content ;}}
6. activate the plug-in and open a link. The plug-in function is shown as follows:
Ghost (1) hello world, wordpresshello WORDPRESS Plugin Development and Learning Series article first, append a fixed character Hello World 1 after each article. open w...