How to Create Your First WordPress Plugin Step by Step (Beginner Guide)

WordPress plugins allow you to add new features to your website without changing the core WordPress files. In this tutorial, I will show you how to create your first WordPress plugin step by step, even if you are a beginner.

By the end of this guide, you will have a working custom plugin that adds a feature to your site.


βœ… What You Need

  • A WordPress website installed

  • Access to your hosting file manager or FTP

  • Basic knowledge of PHP (not required, but helpful)


πŸ“ Step 1: Create Plugin Folder

Go to:

/wp-content/plugins/

Create a new folder:

my-first-plugin

πŸ“„ Step 2: Create Main Plugin File

Inside that folder, create a file:

my-first-plugin.php

🧠 Step 3: Add Plugin Header Code

Open my-first-plugin.php and paste this:

<?php
/**
* Plugin Name: My First Plugin
* Plugin URI: https://yourwebsite.com
* Description: This is my first WordPress plugin.
* Version: 1.0
* Author: Your Name
* Author URI: https://yourwebsite.com
*/

Save the file.


πŸ”Œ Step 4: Activate the Plugin

Go to:

WordPress Dashboard β†’ Plugins β†’ Installed Plugins

You will see:

My First Plugin

Click Activate.

πŸŽ‰ Congratulations! You have created your first WordPress plugin.


πŸ›  Step 5: Add a Simple Feature

Now let’s make the plugin do something.

Add this code below the header:

add_action('wp_footer', 'mfp_show_message');

function mfp_show_message() {
echo ‘<p style=”text-align:center;color:green;”>My First Plugin is working!</p>’;
}

Save the file and refresh your website.

βœ… You will see a message in the footer of your site.


πŸ§ͺ How This Works

  • add_action() connects your function to WordPress

  • wp_footer runs when the footer loads

  • echo prints text on the screen


πŸ“¦ Final Plugin Code

Your complete file should look like this:

<?php
/**
* Plugin Name: My First Plugin
* Plugin URI: https://yourwebsite.com
* Description: This is my first WordPress plugin.
* Version: 1.0
* Author: Your Name
* Author URI: https://yourwebsite.com
*/
add_action(‘wp_footer’, ‘mfp_show_message’);

function mfp_show_message() {
echo ‘<p style=”text-align:center;color:green;”>My First Plugin is working!</p>’;
}


πŸš€ What You Learned

  • How WordPress plugins work

  • How to create a plugin folder and file

  • How to register a plugin

  • How to add functionality using hooks


πŸ”œ What’s Next?

In the next tutorial, we will learn:

  • How to add admin menu to a plugin

  • How to create plugin settings page

  • How to build real plugins


🏁 Conclusion

Creating a WordPress plugin is not difficult if you understand the basics. This is your first step into WordPress plugin development.

If you have any questions, feel free to ask in the comments.

Leave a Comment