Basic WordPress Plugin Development

  • Post last modified:Last updated on September 30, 2026
  • Post author:By

Are you interested in creating your own WordPress plugin?

This step-by-step tutorial will teach you the basics of creating a WordPress plugin from scratch. You’ll learn how plugins are structured and how to add custom functionality using WordPress hooks. If you can read basic PHP, you can follow along — no advanced programming required.

Prefer to watch? Here’s the video walkthrough:

What is a WordPress plugin?

A WordPress plugin is a package of code that adds features to your site. Every plugin lives in its own folder inside wp-content/plugins/. At minimum, a plugin is a single PHP file with a special header comment that tells WordPress “I’m a plugin.”

Plugins can do anything from tiny tweaks (like adding a message after each post) to full applications (like turning WordPress into an online store).

What you’ll need

  • A WordPress site to experiment on — a local install or staging site is ideal, so mistakes don’t affect visitors.
  • A plain text editor (Notepad, VS Code, or similar).
  • A way to access your site’s files: FTP, your host’s file manager, or the built-in Plugin File Editor.

Back up first. Before touching any code, make sure you have a recent backup. A free plugin like UpdraftPlus takes minutes to set up and can save you hours.

Step 1: Create the plugin folder and file

In wp-content/plugins/, create a new folder called my-first-plugin. Inside it, create a file called my-first-plugin.php.

Giving the folder and the main file the same name is a WordPress convention — it keeps things tidy and avoids conflicts.

Step 2: Add the plugin header

Open my-first-plugin.php and paste this at the top:

<?php
/**
 * Plugin Name: My First Plugin
 * Description: Adds a thank-you message after post content.
 * Version: 1.0
 * Author: GetStartedWP
 */

That comment block is the plugin header. It’s how WordPress recognizes the file as a plugin. If you go to Plugins > Installed Plugins now, you’ll see “My First Plugin” listed — but activating it does nothing yet, because we haven’t added any functionality.

Step 3: Add functionality with a filter

WordPress has a system called hooks that lets plugins tap into what WordPress is doing. A filter hook lets you modify a piece of data — like post content — before it’s displayed.

Add this below the header:

if ( ! defined( 'ABSPATH' ) ) exit;

function gswp_thank_you_message( $content ) {
    if ( is_single() ) {
        $content .= '<p><em>Thanks for reading! If this tutorial helped, share it with a friend.</em></p>';
    }
    return $content;
}
add_filter( 'the_content', 'gswp_thank_you_message' );

Here’s what each part does:

  • if ( ! defined( 'ABSPATH' ) ) exit; — a security line that stops the file from running if accessed directly.
  • The function takes the post content, appends a message to it, and returns the result. The is_single() check means it only runs on individual post pages, not archives.
  • add_filter( 'the_content', ... ) — attaches our function to WordPress’s the_content filter, which processes every post’s content before display.

Step 4: Activate and test

Go to Plugins > Installed Plugins, find “My First Plugin,” and click Activate. Open any blog post on your site — you should see your thank-you message below the content.

If something breaks, don’t panic: rename the plugin folder via FTP and WordPress will deactivate it automatically.

Where to go next

You just built a working WordPress plugin from scratch. Everything else in plugin development is a variation on what you did here: hook into WordPress at the right moment, and run your code.

Editorial Team

The GetStartedWP editorial team is a team of WordPress experts and developers. We are passionate about creating and sharing content like tutorials and guides about the entire WordPress ecosystem.

Disclousure: Our content is reader-supported. This means if you click on some of our links, then we may earn a small commission.

Leave a Reply