How To Create A Custom WordPress Functions Plugin [2024]

Learning how to make a WordPress function.php Plugin can go a long way to help reduce the number of plugins you need to install on your WordPress website, this article will guide you on how to create a WordPress custom functions.php file easily instead of breaking your site through the theme function file.

This custom functions.php behaves just like a WordPress plugin and it is very effective all across the website, unlike a regular plugin that its functions.php file only works in the plugin directory.

The majority of website owners or bloggers love an easy way to do things and then resort to editing the theme functions file which most time usually breaks the site and creates a compound issue that may later take beginners time to fix while some will need to pay a professional to fix them.

How To Create A Custom WordPress Functions Plugin
How to create functions.php plugin in WordPress.

Here we will make this easy for both WordPress beginners and experienced WordPress bloggers, even if you have a mixup in your custom functions.php file we will give you a quick fix to undo what has been done. Isn’t that interesting?

The fact remains, that this is the best practice in adding code snippets to your site and this is much more easier and beneficial than using a third-party plugin.

WordPress is an Open Source Content Management system that gives us the opportunity to customize it to our taste and of all CMS (WordPress, Joomla, Wix, Squarespace, Drupal e.t.c) WordPress is the most used CMS and this is because of its flexibility.

You must have come across some snippet on the internet where you are being told to copy a code and paste it into your theme functions.php file, most web tutorial sites usually advise against directly editing the theme function and recommend creating your own functions or using a third party functions plugin.

You may find it hard to believe it that on this website I only have four plugins (4), this is a great boost for this blog and the function file was used to handle my Google analytics code (gtag.js) and also further optimize my blog for speed.

This article will help you avoid directly editing your theme functions and also make you avoid third-party plugins so we urge you to pay attention to this tutorial as it will benefit you more and even help cut out other plugins thereby reducing the number of plugins you have on your website.

Before we dive into the main topic let us quickly highlight the dangers of editing the theme functions and the benefits of having a custom WordPress functions.php file.

Dangers Associated With The Direct Editing Of Theme Functions

  • It could break your site
  • When you update your theme you lose all custom functions
  • May get your host to disable your website
  • Can make Google flag your site
  • It can make your blogging career miserable

Importance Of Having A Custom Functions Plugin

Here are the reasons why you need to use a custom functions.php plugin:

  1. You don’t lose custom functions when the theme is updated or changed
  2. Add Google Analytics code in the head or footer of the site
  3. To remove new nav menus
  4. Can be used to add a widget section
  5. Add your site link to all articles when a post is being copied
  6. Add a Social Share button with no JavaScript
  7. Add Social Follow buttons
  8. Used to add Google Adsense and other ads header script
  9. Can be used to add Adsense and other Ads units in different locations or paragraphs
  10. Deactivate feeds link (feed, RSS feeds, e.t.c.)

The list is endless and not limited to the listed, you can also Optimize the site by disabling running scripts that are not needed, removing WP shortlinks, disabling emoticons, remove query strings from static resources.

It can also be used to disable XML and RPC, remove WordPress version, remove Wlwmanifest link, disable self pingback, disable dashicon, remove jetpack unused css, remove unused Gutenberg Block Library css, reduce post revisions, e.t.c.

Now that you know the dangers of editing theme functions directly and also you know what to gain if you learn how to make a function.php plugin yourself then I think now is the time to reveal the simple secret to you.

Creating a Custom WordPress Functions Plugin (Functions.php File)

The WordPress custom functionality plugin we are about to create will be stored in the wp-content/plugins directory so you need to locate that through FTP or cPanel File Manager.

Mind you, this functions plugin can also be created on your mobile phone or PC by using a text editor or Notepad++.

  • Create a folder then name it â€śyoursitename-custom-functions”
  • After the folder has been created open it
  • Inside of the folder create a file named “yoursitename-custom-functions.php”
  • Use an editor to open the file then copy and and paste the code below and hit save
<?php
/**
 * Plugin Name: ZudoTech Web Solutions
 * Version:     1.0.0
 * Description: My Function Panel
 * Author:      ZudoTech
 * Author URI:  https://zudotech.com/
 * License: GPL2
 */
/* Start Adding Functions Below this Line */   

YOUR CODE SNIPPETS HERE!!!

/* Stop Adding Functions Below this Line */
?>

If you created the file on your mobile phone or on your PC then you need to zip the file then login to WordPress Dashboard and navigate to Plugins> Add New> Upload and here you can upload the zip file you just created and activate the plugin.

Once successfully uploaded you now have a fully functional WordPress plugin for editing functions.php and from this, you can always add any code snippet that you need to add to your functions.php.

We have listed some instances where you can use this simple yet powerful plugin and below we will show you how to hide Screen Options button on WordPress Dashboard, also you can browse this website for more codes especially on how to optimize WordPress.

<?php
/**
 * Plugin Name: ZudoTech Web Solutions
 * Version:     1.0.0
 * Description: My Function Panel
 * Author:      ZudoTech
 * Author URI:  https://zudotech.com/
 * License: GPL2
 */
/* Start Adding Functions Below this Line */   


// Delete screen options button from Dashboard Start
 function remove_screen_options(){
    return false;
    }
add_filter(screen_options_show_screen, remove_screen_options);
// Delete screen options button from Dashboard End


/* Stop Adding Functions Below this Line */
?>

For easy editing we have compressed the code above and made the plugin for you which can be downloaded below, all you need to do is to edit and add more functions to it which can easily be done through FTP or cPanel file manager.

Download File

NOTE: If you encounter any issue all you have to do is deactivate the plugin or delete from the cPanel File Manager (wp-content/plugins) and your site will be back.

Conclusion On How To Create A Custom WordPress Functions Plugin

Working with WordPress has always been an interesting thing to do and with this new knowledge of yours on how to create a WordPress custom functions.php Plugin, you can disable or enable new theme features either in PHP or in the WordPress built-in file, in short, it allows you to define your own functions.

Do you enjoy reading this? Leave a comment in the comment section, if you experience any difficulty setting this up we can point you in the right direction.

Share 💞:

Similar Posts

Leave a Reply