WordPress Plugin Tutorial - Hello World
Posted on May 15th, 2008
Learning to develop a WordPress plugin can be both fun and rewarding. In this Tutorial we will go over how to make a simple Hello World plugin that you can create. This will give you a very basic understanding of how to create a simple WordPress plugin that we can build on in future tutorials.
To begin with create a folder in your wp-content/plugins/ folder called helloworld.
Next create a file in a text editor called helloword.php.
Add the following lines of code to the helloword.php file…
<?php
/*
Plugin Name: Hello World
Plugin URI: http://www.yourdomain.ca
Description: A simple Hello Word Plugin
Version: 1
Author: John Doe
Author URI: http://www.yourdomain.ca
*/
The above code creates the information pulled in to the Plugins page of your WordPress admin. Plugin URI should point to the site where you will provide updates and install details for a plugin. The other information above you can edit to be your own details.
Now add the following code to the bottom of the helloworld.php file…
function hello_world() {
Print(”Hello World”);
}
?>
The above code will output Hello World when the plugin is called from one of your pages. Upload the helloworld.php file to your helloworld folder and activate the Hello World plugin in your WordPress admin.
Last step is to add the plugin to a page so you can see the plugin. To do that add the following code to the bottom of your index.php file in your theme…
<?php
if(function_exists(’hello_world’))
{
hello_world();
}
?>
Be sure to upload the change to your index.php file and refresh your main page. If you placed it at the bottom of your page you should see it now if you scroll to the bottom of your page. You can remove the plugin from your page by deactivating it.
Although this example may not be exciting it is a good start to the understanding of how to create plugin. In our next example we will build of this so you can learn how to make more advanced WordPress plugins.
If you get stuck let me know in the comments.
Posted in Development | 226 views
Related Topics:
WordPress Plugin Tutorial - Hello World Continue
Small Business Brief WordPress Plugin - Beta
DealDotCom WordPress Plugin - Beta
WordPress Plugin To Build RSS Subscriptions
PHP Tutorial - Part 2 of 5
1 Comment
Sorry, the comment form is closed at this time.




[...] of 2007, and I haven't linked to his blog even once. Take a look at the two plugin tutorials: WordPress Plugin Tutorial - Hello World and WordPress Plugin Tutorial - Hello World Continue (I think he forgot an "s" at the end [...]