Skip to Main Content

How to Create a WordPress Plugin Quickly

Divi: the easiest WordPress theme to use

Divi: The best WordPress theme of all time!

With over 901.000 downloads, Divi is the most popular WordPress theme in the world. It is complete, easy to use and comes with more than 62 free templates. [Recommended]

You are certainly wondering why I propose a tutorial quite difficult to understand. The reason is that as a WordPress user or developer, we always have to modify the behavior of WordPress especially by using the plugins.

However, any modification of the behavior of WordPress does not necessarily give place to a configuration interface, hence the notion of " out-of-the-box ". And very often, for the activation or deactivation of a WordPress feature, a few lines of code suffice.

In reality, add these codes in the active theme file (functions.php) is a good idea, but it is not a good idea when the theme is updated automatically or when you change the theme, hence the initiative to create your own plugin.

What are the prerequisites?

A priori for a basic plugin, I'll say, " you only need to be attentive ". You do not need anything to the extent that I will provide you with quite detailed codes on some " Hacks Of WordPress, and you will simply copy them to the main file of your plugin.

If you plan to create complete plugins, then you will need to learn how to use "PHP / Mysql" on the one hand and master the "API" of WordPress (Interface Programming Interface).

You must also remember that we are in a test situation and for good reason, you must have a specific environment installed at home or online, but this environment should not be used for production.

Basically do not test what you learn on your main blog.

Easily create your website with Elementor

Elementor allows you to easily create any website design with a professional look. Stop paying expensive for what you can do yourself. [Free]

Creating a simple plugin

All you need to do is to create a folder named as you want containing a file with the same name, but written under the extension " . Php ».

In this exercise, we will create a file named " plugin-wordpress.php »Included in a folder« plugin-wordpress That we are going to copy somewhere on our computer.

wordpress plugin-image

Open this file with a text editor of your choice. But I advise you to install "notepad ++", which is lightweight and very easy to use.

Start by writing an opening php tag <? php ". This is how any php file starts. The closing tag (?>), it's not mandatory.

Stop wasting time and money!

Discover the best tool to create your blog, your online store blog or any other website in just a few clicks!

beginning-of-the-drafting

Once done, we will create the file header. For that, you must first open the comments. That is, using " /* And closing with " */ ».

change-plugin

Now that the header is ready, we will define the plugin information, including:

  • The plugin name (Plugin Name: WordPress plugin example)
  • the plugin description (Description: your description)
  • the name of the author (Author: Your name)
  • The plugin version (Version: 1.0 or 2.0 at your leisure).

plugin-details

This is basic information, but other information is available on the WordPress Codex.

Once it's done ... well, your plugin is ready, but it's not doing anything for the moment. You can now compress your plugin in the " zip And install it on WordPress. Yes yes, you can do it. Here is what your plugin will look like once installed.

exmple de plugin

It's in the file plugin-wordpress.php That you will add your different PHP codes that I will propose to you in the future or yours.

That's it for this tutorial on creating a simple WordPress plugin.

This article features 5 comments

  1. Hello,

    I followed your steps to create a plugin but when I want to install it on wordpress, I get the following message:
    “The archive could not be installed. No valid extension found.
    Extension installation failed. "

    However, I put the same code as you.

    Do you know where the problem is?

    Thank you
    Roman

      1. Hello,

        i tried with firefox, chrome and IE, it doesn't work.
        i also tried uploading it via ftp, i still have nothing;
        I do not understand

        Are there any other points to check?

        Roman

        1. "For the plugin to be recognized by WordPress, you must necessarily declare at least its name in the main file. We do this via a comment at the beginning of the file. "

          <?php
          /*
          Plugin Name: Plugin Name
          */

Leave a comment

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

This site uses Akismet to reduce unwanted. Learn more about how your comments data is used.

Back To Top
6 shares
Share2
tweet4
Save