WORDPRESS plugin development and learning (1) hello world, wordpresshello

Source: Internet
Author: User

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
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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.