• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

How To Build A Plugin In WordPress (Step by Step)

Bhagwad Park

Published on: September 6, 2018

Categories: WordPress 0

You can’t call yourself a true WordPress expert until you’ve built at least one plugin of your own. Perhaps you want to distribute it for use on the WordPress plugin repository, or maybe you prefer an approach like hosting it on GitHub. Or you might even develop a plugin just for one site! Something that’s uniquely tailored to your needs and which you’ll never have to show another person.

Whatever your reasons, this tutorial will show you how to build your own plugin in WordPress and install it without any need for FTP. Bonus instructions at the end of the article for how you can submit it for distribution to WordPress.org!

Step 1: Create a Plugin Folder with a File

The first step is to choose a name for your plugin. This actually consists of two things:

  1. The actual title that you want others to see and which will show up in the plugins page
  2. The “slug” that’s like the URL slug for your posts

Take (b), and create a folder using the slug as the folder name. Inside that folder, create a file with the “PHP” extension – again using the slug as the name. For example, I’m going to create a plugin with the following:

  1. Plugin name: “My New Plugin Name”
  2. Slug: “new-plugin”

So here’s my new folder with the plugin file inside it:

Create a New Folder and PHP File with the WordPress Plugin Name

Step 2: Add Basic Code to the PHP File

The file with the PHP extension is where you’ll place the PHP code for your plugin functionality. But before we start adding code, we need to add some plugin headers to give WordPress basic information about it. There are a lot of headers, but the only one that’s truly mandatory is the “Plugin Name”. Use the following code to get started:

<?php

/*
Plugin Name: My New Plugin Name
Description: A New Plugin from Scratch!
*/

Note that I haven’t included the closing ?> PHP tag. This is by design. The best practice for WordPress PHP files is to leave out the closing PHP tag for the file. The reason is that it’s dangerous and can cause your site to crash if there’s even a single space or newline after it. And it’s almost impossible to debug!

After these comments, you can place your actual plugin PHP code.

Step 3: Zip the folder with the file

Using the regular “Send to zipped file” functionality of Windows. Right-click the folder, click “Send to” and choose “Compressed (zipped) folder” as shown here:

Create a Zipped File with the Plugin

Make sure the name of the zipped file is the same as your plugin “slug” that we saw in Step 1.

Step 4: Upload the Plugin to WordPress

Now log into WordPress and go to “Plugins -> Add New”. Click “Choose File” and “Install Now” as shown here:

Install New Plugin

This will upload the zipped file and allow you to activate the plugin. After activation, you can see it in your Plugins dashboard like this:

How to Build a Plugin in WordPress

You’re done! You’ve just built a plugin for WordPress! Remember to add your PHP code below the plugin header under the comment section – otherwise, it won’t do anything.

(Optional) Step 5: Prepare your File for Upload to WordPress.org

To upload your plugin to the WordPress repository, you need to do a few things:

  1. Add a readme.txt file
  2. Add some more details to the plugin headers

The readme.txt file is critical and has a specific format. You can use this tool to generate it. And once you’re done, you can validate it here.

As for header requirements, the more information you can include in the plugin, the better. Here are a bunch of options from the WordPress documentation, as well as a sample comment header.

Hopefully this tutorial helped you to build your plugin – whether for personal, or public use.

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Related Posts

Joomla vs. WordPress: Which One Is Better?

In this post, we’ll consider five differences between Joomla and WordPress and how you might go forward with setting up a WordPress website.

How To Back Up Your WordPress Site (And Why You Should Do It Today)

In this post, we’ll take a closer look at why backups matter. We’ll also show you different ways to back up your WordPress website.

How To Start A Newsletter In WordPress

Check out our complete guide on why and how you should start your own newsletter in WordPress.

What Is Self-Hosted WordPress?

In this post, we’ll differentiate self-hosted WordPress from WordPress.com, and discuss the benefits of the former.

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA