How to Create Your First Custom WordPress Plugin? | HostAdvice

How to Create Your First Custom WordPress Plugin (Beginner’s Guide)

Do you consider creating a WordPress Plugin? Then, you’ve come to the right place. Our blog will help you learn everything you need to know if you decide to create your first ever WordPress plugin. And worry not, you’ve stumbled upon a beginner-friendly guide, so you won’t need any experience or skill to perform the steps all by yourself.

WordPress is a flexible, easy-to-use, and free website building platform. Many users love WordPress as it offers excellent possibilities for your websites. But what are the plugins? How can they improve your page? In this blog, we’ll guide you into the process of creating your first plugin, and we’ll also try to explain some things you might be unfamiliar with. So, what are we waiting for? Let’s get started!

article banner

What do You Know About Plugins?

WordPress is an excellent platform because of its features and the possibility it offers, and also because of the plugins. Now, some of you might be familiar with this term, but let’s briefly explain it to those who are not. To understand them better, you can imagine plugins like your phone apps. Your phone is already powerful, but it becomes even better with additional apps and provides better performances. Well, it’s kind of the same with the WordPress plugins.

Important: Plugins are helpful tools that improve the user’s WordPress experience by adding all kinds of functionalities. They extend what already exists in this powerful platform.

You can have a plugin that adds some of the following functionalities:

  • Spam protection
  • SEO
  • E-commerce
  • Live chat
  • Better security
  • Advanced forms

These are just some of the features you can get by downloading a plugin. WordPress comes with thousands of excellent free plugins, meaning there is a plugin for almost everything. However, you may still need a feature that isn’t available, so you would need to know how to create a plugin from scratch.

Differences Between Themes and Plugins

You may wonder why this part is important, but most of you don’t know the difference between the plugins and the themes. Although it looks obvious, there are some minor details that you probably haven’t heard of, especially if you’re a beginner. If someone asks you, you would probably say that the theme changes the website’s appearance and that the plugin adds different features. But is that all?

Surprisingly, the theme can also change your page’s functionality. The themes include a functions.php file that contains a code that adds functionalities to your page. This can be useful if you want to add some functions quickly but not write a whole plugin. Adding the code may also help you if you create some theme and you need to include some features.

Warning: If you add code to functions.php, it links with the current theme. If you decide to change the theme, the code won’t be active anymore.

On the other hand, the plugins can make some changes to the website’s look. What’s better about the plugins, they don’t connect to a particular theme, so if you decide to change it, you won’t lose any of your features. Overall, it is easier to use a plugin for adding functionalities as it’s easier to maintain them and share them with others.

How Do Plugins Work?

It’s already clear that the plugins basically ‘plug in’ to WordPress core. To do this, they use ‘hooks’ which determine when and where on your website the plugin will be used. For example, if you have a plugin that changes the error message which appears if you type in a wrong password, the error message would be the hook. The plugin connects to the code that delivers that message and changes the shown text. If we made this clear, let’s move on to the types of ‘hooks.’ WordPress confirms two types of ‘hooks’:

  • Actions: add or change the functionality of WordPress
  • Filters: change the action’s functionalities
Note: There is a lot more about how these ‘hooks’ work, but we won’t go that much into details as this is a beginner-friendly guide.

What Else do You Need to Know?

We know you’re impatient and can’t wait to learn how to create a plugin, but there are still a few things you need to consider before creating your first plugin. However, this won’t take much time. We’ll just quickly explain the main things you need to know.

  • Consider how you’ll use names: this applies to the plugin and to the functions it contains; avoid naming collisions that will occur when more than one element on the site has the same name; choose a unique prefix that will be applied to each function
  • Determine the structure of the plugin: decide if you’ll use a single file for your code, or you’ll spread it across more files; plan the structure of your plugin’s folders
  • Consider the plugin’s security: security is fundamental, so the plugin doesn’t have vulnerabilities;

These are some of the essential things you need to keep in mind before you start creating a plugin. Even though this looks like a lot, there won’t be any problems once you understand the whole process thoroughly.

How to Create Your First Custom WordPress Plugin?

It’s finally time to learn how to create your first ever plugin! This process can be more advanced, but we’ll stick to the basics, and we’ll use a minimum amount of coding. Let’s see how to create a plugin that changes the link text, which displays by inserting a Read More tag in a post or on your website through the following simple steps.

Step #1: Set Up a Testing Environment

Setting a testing environment is a must, whether you create a plugin or make other changes. The testing environment is also known as ‘local environment’ or ‘staging site,’ depending on where your site is stored – on an external server or your computer. The testing environment lets you add and edit the site’s files and functionalities without damaging the actual website.

Warning: The testing environment should be a private copy of your website.

Setting up the testing environment is pretty easy, and we recommend using a tool like DesktopServer, as it’s easier to install a local version of WordPress.

screenshot of ServerPress website

Another option is to create an online staging site that works as a copy of your actual site, but it is available to you and the other admins. To create a copy, you can use

. Later, the copy of the changes can be imported back to the live version of your website.

screenshot of DreamHost website

Step #2: Create a New Plugin File

To start putting together a plugin, you need to access the site’s directory. This can be done by using SFTP, a method that allows you to manage and view your website’s files while they’re on an external server. In our example, we’ll use a client called FileZilla. Startup FileZilla and use the SFTP credentials which your web host provides. After you get in, go to the folder with your plugins that you can find at /wp-content/plugins/.

screenshot of Filezilla (Plugins folder is highlighted)

Inside this directory, create a new folder, and name it as you like. We’ll name ours very-first-plugin.

screenshot of Filezilla (Creating a directory)

In this folder, you’ll create a single file, which will be a PHP file. Then, open the very-first-plugin directory and right-click inside it to create a new file.

screenshot of Filezilla (Creating a new file)

After creating the file, you should name it the same as the folder, so name it very-first-plugin.php. Then, you would need to add some info to the file. This step is of great importance as it will display the plugin’s name, content, and other information. You should right-click on the PHP file and select View/Edit, and when you open the file, this will appear on the screen:

screenshot of very-first-plugin file

Then, paste the following code into it:



* Plugin Name: Very First Plugin

* Plugin URI:

* Description: This is the very first plugin I ever created.

* Version: 1.0

* Author: Your Name Here

* Author URI:


Once you save the file, you will see the plugin in your admin’s dashboard.

screenshot of Very First Plugin in WordPress

Step #3: Add Code to Your Plugin

As we’re creating a plugin that displays the text when you insert a Read More tag, to see what it looks like, create a new blog post and click on the Insert Read More tag icon.

screenshot of WordPress Editor (Read More tag highlighted)

Once you publish the post, the tag will be replaced with a ‘Continue Reading’ link.

screenshot of WordPress page with Highlighted a Continue Reading button

Now, if you want to change this text, open the very-first-plugin.php file again, add a new line and paste the following code:

function dh_modify_read_more_link() {

    return '<a class="more-link" href="' . get_permalink() . '">Click to Read!</a>';


add_filter( 'the_content_more_link', 'dh_modify_read_more_link' );

This function gets the link from the post and applies the Click to Read! text, which replaces Continue Reading.’

screenshot of WordPress page

If you’ve done everything correctly, then the plugin should work, and you’re ready for the last step. If not, check the code to see whether you’ve made some mistakes.

Step #4: Export and Install Your Plugin on a Live Site

Not because it’s the last step, but this step is the easiest. What you need to do is to compress the very-first-plugin folder into a ZIP file. Right-click on the folder and click ‘Compress.’

screenshot of plugin folder

Another way is to download the folder, and once it is downloaded, you can do the same as above.

plugin downloading screenshot

To upload the plugin to your website, open the WordPress admin dashboard, go to Plugins, and click on ‘Add New.’

screenshot of Plugins tab in WordPress

Next, you need to select ‘Upload Plugin,’ select the file and click on ‘Install Now.’

screenshot of Add Plugins page in WordPress

Well done! You’ve successfully created your first WordPress plugin. See how easy that was? We’re pretty sure that you’ll be able to create the next plugin independently.

Final Thoughts – Easy Way to Create Your First Plugin

Although this whole process may have sounded scary to you, we hope you’ll change your opinion after this guide. By reading this blog carefully, many things will become clear to you.

Final verdict: Not only is WordPress powerful, but it also provides excellent opportunities for your website to be even better than you’ve imagined it.

The best way to add new functionalities to this platform is by creating your first WordPress plugin. Don’t be afraid to try and create a plugin. Maybe one day, you’ll host your own plugins in the WordPress Plugin Directory. And if you have a Managed WordPress hosting provider, they might as well assist you in the process!

screenshot of Managed WordPress Hosting Category on HostAdvice

Do you need the best wordpress hosting? Check out for our recommendations by clicking here.

10 Best VPS Hosting on Reddit: Most Recommended Providers 2024

Reddit is a popular source for hosting recommendations, including VPS hosting. With multiple conversations on choosing a service and dozens o...
4 min read
Ela Gal-Kfir
Ela Gal-Kfir
Digital Marketing Specialist

HostAdvice Speaks to ScalaHosting: An Interview with Chris Rusev

HostAdvice had the opportunity to speak with Chris Rusev, the CEO and co-founder of , a web hosting company that offers shared, cloud VPS, and res...
8 min read
Eddie Segal
Eddie Segal
Digital Marketing Specialist

Email Deliverability: What Is It, Key Factors & Best Practices

What is Email Deliverability? Think of it like mailing a letter and making sure it lands right in the recipient's hands, not lost or thrown...
17 min read
Ela Gal-Kfir
Ela Gal-Kfir
Digital Marketing Specialist

Email Marketing vs. Social Media: Which is More Effective?

What is Email Marketing? Email marketing is a  that involves companies reaching out to potential and existing customers via email ...
10 min read
Ela Gal-Kfir
Ela Gal-Kfir
Digital Marketing Specialist provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top