Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

How to Create a WordPress Plugin Using a Plugin (Quick & Easy)

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Do you want to create a WordPress plugin using a plugin?

Beginners may find it difficult to add code to WordPress. By creating a custom WordPress plugin, you can add code to your site without risking any serious errors or issues.

In this article, we’ll show you how to easily create a custom WordPress plugin using another plugin.

How to create a WordPress plugin using a plugin

Why Use a Plugin to Create a Plugin in WordPress?

WordPress is the best website builder in the world because it’s so flexible and customizable. However, at some point, you may want to go further and add custom code to your website.

Often, WordPress guides will ask you to add custom code to your functions.php file. However, this isn’t very user-friendly, and even a small mistake in the code can cause all sorts of common WordPress errors. The custom code may even completely break your website.

Not to mention, you’ll lose all the custom code the next time you update your WordPress theme. For that reason, many website owners create their own plugins instead.

If your custom plugin causes issues, then you can deactivate it just like any other WordPress plugin. You can also update your WordPress theme without losing customization.

With that in mind, let’s see how you can create a WordPress plugin using a plugin. Simply use the quick links below to jump straight to the method you want to use:

The easiest way to create a WordPress plugin is by using WPCode.

This free plugin makes it easy to add custom CSS, PHP, HTML, and more to WordPress without putting your site at risk. You can simply paste the plugin’s code into WPCode’s editor and then activate and deactivate the code with the click of a button.

To start, you’ll need to install and activate WPCode. For more information, see our step-by-step guide on how to install a WordPress plugin.

After that, go to Code Snippets » Add Snippet in the WordPress dashboard.

Creating a plugin using WPCode

Here, you’ll see all the pre-made snippets you can add to your site. This includes a snippet that allows you to completely disable comments, upload file types that WordPress doesn’t usually support, disable attachment pages, and much more.

To create a plugin, hover over ‘Add Your Custom Code’ and then select ‘Use snippet.’

Adding a custom code snippet to WordPress using WPCode

To start, type in a title for the custom plugin. This could be anything that helps you identify the code in your WordPress dashboard.

WordPress plugins are created using PHP, so open the ‘Code Type’ dropdown menu and choose ‘PHP.’

Adding PHP code to a website using WPCode

After that, you can paste or type your code into the code editor. As an example, we’re going to create a simple plugin that shows a random fact in the WordPress dashboard.

Here’s the code we are going to use:

 * @package Random_Fact
 * @version 1.0
Plugin Name: Random Fact
Plugin URI: 
Version: 1.0
Author URI: 

function get_fact() {
	$fact = "There are different sizes of infinity
	The Brontosaurus never existed
	A day on Venus lasts longer than a year on Venus
	The eighth power of a number is a zenzizenzizenzic
	Sharks lived on earth before trees";

	$fact = explode( "\n", $fact );
	return wptexturize( $fact[ mt_rand( 0, count( $fact ) - 1 ) ] );

function hello_fact() {
	$chosen = get_fact();
	echo "<p id='fact'>$chosen</p>";

add_action( 'admin_notices', 'hello_fact' );

function fact_css() {
	$x = is_rtl() ? 'left' : 'right';

	echo "
	<style type='text/css'>
	#fact {
		float: $x;
		padding-$x: 16px;
		padding-top: 6px;		
		margin: 0;
		font-size: 20px;

add_action( 'admin_head', 'fact_css' );


Below the code box, you’ll see some insertion options. There are two main options: Auto Insert and Shortcode (Default).

If you choose ‘Auto Insert,’ then WordPress will automatically insert and execute the code on your website, blog, or online store.

After selecting ‘Auto Insert,’ you can tell WPCode to run the code in the WordPress admin area, the front-end of your website, or everywhere.

Automatically inserting code across your WordPress website

If you choose ‘Shortcode’, then WPCode won’t insert the snippet automatically. Once you save the snippet, WPCode will create a shortcode that allows you to add the code to any page, post, or widget-ready area. This is a good option for code that adds content to your site, such as a pricing table or custom image gallery.

For more information on how to place the shortcode, please see our guide on how to add a shortcode in WordPress.

In this example, we are going to select ‘Auto Insert.’ Then, open the ‘Location’ dropdown and choose ‘Admin Only,’ so the random facts only appear in the WordPress admin area.

Adding custom code to the WordPress admin area

With that done, you may want to add tags to the code snippet.

This can help organize your custom plugins and code snippets by topic and functionality.

Adding tags to a code snippet in WordPress

When you’re ready to publish the custom plugin, scroll to the top of the screen and click on the ‘Inactive’ toggle so it changes to ‘Active.’

Finally, click on ‘Save Snippet’ to make the snippet live.

Publishing a custom plugin using WPCode

Now, the custom plugin will be live on your WordPress website.

In our example, we can see a random fact in the admin area.

Activating a custom WordPress plugin using WPCode

At some point, you may want to deactivate the custom WordPress plugin. This method doesn’t add your custom plugin to Plugins » Installed Plugins, so you’ll need to deactivate the code snippet instead.

Simply head over to Code Snippets » Code Snippets and find your plugin. Then, just click on the toggle so it changes from blue (activate) to grey (deactivated).

Deactivating a custom plugin using WPCode

Method 2. Using Pluginception (Best For Creating Standalone WordPress Plugins)

You can also create a custom plugin using Pluginception. This free plugin allows you to create a new, blank plugin simply by typing in some basic information, such as the plugin’s name and version number.

Unlike WPCode, Pluginception adds the custom plugin to the Plugins » Installed Plugins screen. This makes it a good choice if you want to manage the custom plugin in exactly the same way you manage other plugins.

The first thing you need to do is install and activate the plugin. For more details, see our beginner’s guide on how to install a WordPress plugin.

After that, go to Plugins » Create a New Plugin in the WordPress admin panel.

Creating a custom plugin using the Pluginception WordPress plugin

This brings you to a screen where you can enter some information about the custom plugin.

You can simply type in a title, but it’s a good idea to add as much information as possible, especially if you share the dashboard with other people.

For example, if you have a multi-author WordPress blog or manage guest bloggers, then this information can help other authors understand what the plugin does.

Adding the information for a custom WordPress plugin

When you are happy with the information you’ve entered, click on the following button: Create a blank plugin and activate it!

This brings you to the plugin editor screen. You’ll see that Pluginception has already added all the information to a new PHP file.

Adding custom PHP to a WordPress blog or website

To create the plugin, simply type your code at the bottom of the file.

Another option is to paste code snippets from the web into the code editor.

Adding custom code to the WordPress plugin file editor

When you’re happy with the code you’ve entered, click on the Update File button.

If your code doesn’t have any errors, then the plugin will now be active on your WordPress blog or website.

If there is a mistake in your code, then you’ll get an error message.

An example of a coding error

In this case, simply fix the error and then click on ‘Update File’ to make the plugin live.

You can now activate, deactivate, and delete the custom plugin just like any other plugin. Simply head over to Plugins » Installed Plugins, and find the custom plugin, and then make your changes.

The WordPress Installed Plugins screen

At some point, you may want to change the plugin’s code. For example, you may need to fix a security vulnerability or add a missing feature.

To update the plugin, head over to Plugins » Plugin File Editor.

The WordPress plugin file editor

Here, open the ‘Select plugin to edit’ dropdown and choose the plugin you want to edit.

With that done, go ahead and click on ‘Select.’

Updating a custom WordPress plugin using a plugin

You can now change the plugin’s code.

When you’re happy with the changes, just click on ‘Update File.’

Updating a custom plugin file

Now, the updated plugin will be live on your website.

We hope that this article helped you learn how to create a WordPress plugin using a plugin. Next, you may want to see our guide on how to choose the best web design software or our expert pick of the best drag-and-drop WordPress page builders.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

6 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Kevin says

    I use this plugin but my website crashed. i havw my own server with ubuntu can anyone tell me where are those files so I can delete them or what can I do?

  3. Piet says

    Nice title, had me clicking through from rss at least, but as Otto writes, the only reason he made this plugin is because he finds it a pain to upload a new plugin via FTP:

    “Having to then encapsulate it into a plugin, fire up Filezilla, navigate, upload the plugin… It’s a pain. This gives me an easy way to create a new blank plugin and go to the editor to paste in the known working code.”

    This plugin does not “create” anything, apart from a plugin header. If you want to add other plugin files, you’ll still need to “fire up Filezilla” and the rest.

    • Otto says

      It creates the subdirectory for the plugin, the plugin php file, and populates the plugin header. Simple, but a handy time saver. And smaller snippet type plugins tend to be one-file anyway.

      Future versions might have options to create simple template code or something. Like a checkbox that says “add a widget”, maybe.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.