# How to Create a WordPress Plugin: A Basic Guide for Beginners

> Learn how to create a WordPress plugin step by step: folder structure, main file, header and basic functionality. A guide for beginners.

URL: https://codegea.com/en/how-to-create-a-wordpress-plugin-basic-guide-for-beginners
CMS · 2025-01-26 · Derian Pinto

## Introduction

Creating your own WordPress plugin can sound intimidating, but don't worry. In this guide I will walk you step by step through the process of building a basic plugin. You don't need to be a programming expert to follow these steps; you just need a bit of patience and curiosity. Let's get to it!

### Step 1: Understand What a WordPress Plugin Is

A plugin is an add-on that adds features to your WordPress site without modifying the core of the system. It can be as simple as a small script that displays a message, or as complex as a customer management system.

### Step 2: Set Up Your Development Environment

Before you start writing code, make sure you have a suitable development environment. You will need:

- A local WordPress site to test your plugin (you can use tools such as XAMPP or Local by Flywheel).
- A code editor (I recommend Visual Studio Code or Sublime Text).

### Step 3: Create the Plugin Folder

1. **Go to the Plugins Folder:** Go to the ***wp-content/plugins*** folder of your WordPress installation.
2. **Create a New Folder:** Name this folder whatever you like; in this example we will call it ***my-first-plugin***.

### Step 4: Create the Plugin's Main File

Inside your new ***my-first-plugin*** folder, create a PHP file with the same name: ***my-first-plugin.php***. This file will be the entry point of your plugin.

### Step 5: Add the Plugin Header

Open ***my-first-plugin.php*** in your code editor and add the following header:

```php
<?php
/*
Plugin Name: My First Plugin
Plugin URI: http://yoursite.com/my-first-plugin
Description: A basic example plugin.
Version: 1.0
Author: Your Name
Author URI: http://yoursite.com
License: GPL2
*/
?>
```

This header is crucial because WordPress uses it to get information about your plugin.

### Step 6: Add Basic Functionality

Let's start with something simple: having our plugin show a message at the bottom of every post.

1. **Write the Function:** Add the following function after the header:

```php
function show_message() {
    echo "<p>Thanks for reading this post.</p>";
}
```

1. **Hook the Function into WordPress:** Use the ***the_content*** hook to add our message to the content of posts:

```php
add_filter('the_content', 'show_message');
```

Your ***my-first-plugin.php*** file should look like this:

```php
<?php
/*
Plugin Name: My First Plugin
Plugin URI: http://yoursite.com/my-first-plugin
Description: A basic example plugin.
Version: 1.0
Author: Your Name
Author URI: http://yoursite.com
License: GPL2
*/

function show_message() {
    echo "<p>Thanks for reading this post.</p>";
}

add_filter('the_content', 'show_message');
?>
```

### Step 7: Activate Your Plugin

1. **Upload the Plugin to WordPress:** If you are working in a local environment, just make sure your folder and file are in ***wp-content/plugins/my-first-plugin***.
2. **Activate It from the WordPress Admin:** Go to ***Plugins*** in your WordPress admin panel, look for "My First Plugin" and click "Activate".

### Step 8: Test Your Plugin

Visit one of your posts and you should see the message "Thanks for reading this post." at the end of the content. Congratulations, you have created your first WordPress plugin!

## Conclusion

Creating a WordPress plugin is simpler than it seems, isn't it? This is just the tip of the iceberg. From here, you can explore more advanced features, interact with databases, build custom forms and much more. What matters is that you now have a solid base to start experimenting and extending your site's features. Good luck and happy coding!
