Skip to content

Creating a Simple WordPress Plugin, Under the Hood

WordPress plugins are where a developer who’s first branching out from themes is likely to go. The speed bump someone like that is likely to hit is simply making a plugin: where do I put what? What do I need? What makes a plugin activate-able?

In this Quick Guide we cover exactly that stuff. What do you need to make WordPress recognize it, and what should a plugin do. The short answer: not what we did in this video. :p

This plugin is (kind of intentionally) silly and useless. Because our focus in the Quick Guide is simple making a first WordPress plugin that does anything at all. Including taking down your WordPress site. SO: DO NOT SLAVISHLY FOLLOW THIS TUTORIAL ON A LIVE SITE YOU AREN’T READY TO WHITESCREEN.

That warning out of the way, here’s the video that explains what we’ve done in the Quick Guide, and what it tells us about WordPress plugins themselves.

Making Your First WordPress Plugin: Breaking Your Site

  1. In a file browser — your local operating system one if you’re using WAMP or MAMP, an (S)FTP client if you’re working on a remote server — open up your content directory. It’s usually wp-content.
  2. In wp-content, open the plugins folder.
  3. Create a new folder inside of your plugins folder. Name it something like myplugin.
  4. In that folder, create a file. The convention is to match your folder name with a .php at the end. This isn’t required though. But to fit that example, create a file called myplugin.php.
  5. In that folder, place in the plugin comment header. Modify it to match your desires. (That is, keep the things to the left of the colons (:), but change the things to the right to whatever you want them to be.
  6. Go into your WordPress admin area. On the page Plugins > Installed Plugins, you should now see the plugin you named in step 5. Activate your plugin.
  7. IF YOU WANT TO BREAK YOUR SITE, add a line of PHP to your file, like die('my plugin was here');. If you don’t want to break it, write some valid and non-breaking PHP instead. (That’s a big task, but we have to draw the line somewhere in this tutorial.) The code from the previous Quick Guide — about using WP_Query in a shortcode — is a good example.

Here’s all the code from this tutorial in one block. A final warning: this code is intentionally capable of making your WordPress site break. die is not a joke.

<?php
/*
Plugin Name: Quick Guide
Plugin URI: https://wpshout.com/quick-guides/
Description: For Quick Guides
Version: 0.1.0
Author: WPShout
Author URI: https://wpshout.com/
*/

die('my plugin was here');

For a more in-depth WordPress plugin creation example, see our full-length article:

Writing a WordPress Plugin From Scratch: A Step-by-Step Tutorial

 

Yay! 🎉 You made it to the end of the article!
David Hayes

0 Comments
Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

0
Would love your thoughts, please comment.x

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

20 Best Free WordPress Themes for 2024 (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...