WordPress – plugin – hello world

WordPress is a blogging software that runs on a webserver, the great thing about wordpress is that you are able to extend the functions to create the pages/comments/archives etc on the blogging site. You are also able to create your own themes that will use the functions that you can create within that theme So lets it straight, a plugin for the wordpress is the way that you can extend the functional aspects of the whole site that is not dependent on the theme that you using (a theme is what you view on the web page the “style” (css) of the site for example).

There is two main directories within the wordpress directory structure to add in new themes (wp-content/themes) and the plugins (wp-content/plugins) this is where you place the code to extend the basic wordpress install.

In this example I going to extend the action get_header, if you save the code below into the directory wp-content/plugins/codingfriends_helloworld as codingfriends_helloworld.php

Plugin Name: Coding friends hello world
Plugin URI: http://www.codingfriends.com/
Description: Outputs hello world
Version: 0.1
Author: Genux
Author URI: http://www.codingfriends.com
License: GPL2
function codingfriends_helloworld()
  echo "hello world";
add_action('get_header', 'codingfriends_helloworld');

once you have saved that file, then goto your wordpress admin page, on the left is the Plugins link, click on that and within there will be the “new” plugin called coding friends hello world, you just need to activate it and then hey presto it works. There will be “hello world” at the top of the wordpress installed pages within the main site (not the wp-admin part of the site).

What is happening is that you have created a function called codingfriends_hellworld, which outputs “hello world”, but the main part is the


this will add this function to a defined plugin action (to get a list of all of the actions (these happen within the core site), and filters (alter text within the site, e.g. pages that you add to the site, comments etc) you can use look here).

So when the action get_header is called within the main wordpress application, it will call your new function (codingfriends_helloworld).

There is tons of things that you can do with these, alter the comments when posted back to the site, pages etc, just look at the API list.

9 thoughts on “WordPress – plugin – hello world”

  1. i have done all things said but still there is no plugin name codingfriends_helloworld in plugins link

  2. I have used xampp and please tell me where it is located too(where can i see the new plugin) coz i have activated the defalult plugin but still i cant see the plugin in my website name test

  3. Ok i got it.I didn,t copy the commented lines(/*…..*/)so that was my mistake .I thought that was comment but didn,t realize that it was header format.So i see and activated too but again i am confused for the reason behind this small experiment coz i just appear at the top left corner of my site and is not even inspected by the firebug.
    could u tell me your reason please.
    And also some code for making a simple form with buttons and textfields in wordpress and using xammp.
    Help me to understand i am beginer

  4. Hi Casual cases, using xammp is fine, you just need to figure out how to do the plugin for the buttons and textfields, if you need some help on a project please contact me and I am will try to help you out.


  5. thanks for the reply
    i used your above code and make a form
    Plugin Name: A simple form
    Plugin URI: http://www.codingfriends.com/
    Description: Outputs a form
    Version: 0.1
    Author: Genux
    Author URI: http://www.codingfriends.com
    License: GPL2
    function form()
    echo "
    Phone No:
    function form_css()
    echo “”;


    Now what i want is to give name,id,action ,method and also the css attributes .I did try like<input type-"button" id="b1" name='b1" but error occurred so i am stuck .Please tell me how to give the form borders,height,width etc(css attributes).

  6. i m sorry but i cant paste u my code i did write
    echo and inside it all tags related to them.
    I post twice it hoping that it was a mistake but again the result is same
    So i hope u dnt mind

  7. no problems at all, did you try to add in

    echo "<input type="button" id="b1"/>";


  8. yea it works.Thanks
    Now that i have made a form,i want to post the form data to a fxn insert() and then it will insert the values in the wordpress databse to my table named wp_test.
    I read $wpdb class and should be declare global this and that but still i dont get any idea.Please help to post,connect and insert values to the table in wordpress.
    Is there any concept of mvc as in code igniter?
    the solution above work for me but its crazy to insert (\”\”) in every time.Are there other alternatives?
    Why cant we just write as in simple html form?

Leave a Reply

Your email address will not be published. Required fields are marked *