Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

What, Why, and How-To’s of Creating a Site-Specific WordPress Plugin

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
What, Why, and How-To’s of Creating a Site-Specific WordPress Plugin

While creating the WPBeginner re-design, we saw a huge mistake that we made in our old site. All of our extra functionality that we added overtime was added in our old theme’s functions.php file. This not only caused our functions.php file to be super bloated, but it also increased the chance of error every time we modified that file. It was then we decided to take the advice of @otto42 and created a site-specific plugin. So you are probably wondering what a site-specific plugin is, why you need it, and how you can have it for your WordPress site. That is exactly what we plan to share in this article, so keep on reading.

What is a Site-Specific Plugin

Site-Specific WordPress plugin is a specific place to add snippets that you find on the web that performs functions that are not theme related. In other words:

Time to time again, you will read “how-to” articles related to WordPress all around the web (including our site) where we share snippets and suggest that you add them into your theme’s functions.php file. These snippets are not huge enough to be justified as plugins of their own, but some of them are certainly great to add specific functionality to a site that is not theme-dependent such as redirecting users to random post. Whereas other functions can be key to your specific site such as Custom Post Types.

This is when you need to add a site-specific plugin which essentially will serve as the same purpose of your theme’s functions.php file, but it will allow you to retain all these functionality when you are changing themes (see our checklist of things to do when changing WordPress themes).

Why You need a Site-Specfic Plugin for WordPress

As we mentioned above, it will allow you to retain all key additions to your site that you may have done overtime. Some functions that belong in a site specific plugin would be Custom Post Types, Adding Shortcodes, Adding WordPress Thumbnail Support, Redirecting users to a Random Post, and other independent functions that does not rely on your theme.

Above functions are something that you will need whether you change your theme or not. Can you imagine disabling a theme and then losing all of your shortocdes? That would be a total nightmare.

One of the reasons why we pasted beginner’s guide to pasting snippets from the web in WordPress was to prevent white screen of death that users get when pasting the snippet with wrong formatting. Often new users simply edit themes using the WordPress back-end to prevent the user of FTP. We have helped countless users who got locked out of their site when they pasted the wrong snippet.

When you use a site-specific plugin, you somewhat have a break-proof site. When you paste a snippet with wrong formatting, instead of the white screen of death the built-in plugin editor will recognize the error, and it will deactivate the plugin. Ofcourse this will break your site for a few seconds but at least you can go to the admin panel and rectify your mistake.

It is like choosing lesser of two-evils. Would you rather be locked out and have the site be broken. Or would you rather have the site broken but have the ability to fix it in seconds by simply undoing your mistake.

How to Create a Site-Specific WordPress Plugin

You may think that it may be super hard, but it really is not.

  • All you have to do is create a new folder in the plugins directory. Example: /wp-content/plugins/yoursitename-plugin/
  • Open a blank file and save it as “yoursitename-plugin.php”
  • Put the following code in the file:
    Plugin Name: Site Plugin for
    Description: Site specific code changes for
    /* Start Adding Functions Below this Line */
    /* Stop Adding Functions Below this Line */
  • Now upload this file into the folder you created in the plugins directory. Then simply activate the plugin.

From this point on, we will recommend adding the appropriate snippets we share into site-specific plugins rather than theme’s functions.php file.

We hope this will start a new trend that others will follow. We have already joined the band-wagon, and we recommend that you do this as well. It is a best-practice that will save you time in the long-run.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Robert Masters says:

    I’m building a plugin at the moment for a multisite network and I need certain functionality available only in specific sites, so this is a perfect article for me right now.
    I have one question though… do I name the site plugin folder for a site that is created as a subdomain? Example: would it be subdomain-mainsite-plugin or just subdomain-plugin?
    Hope this makes sense, question based on your tutorial.

  2. hans says:

    very good. when you create a second instance don’t forget do give the “register and load” function an own name, like i did ;)

  3. Eric Ellis says:

    That’s great. I always figured it was pretty simple. Thank you for the information.

  4. Jide says:

    Nice one there. Kindly update the post to inform readers that after activating the plugin, they will have to click on the “edit” link on the plugins page, to add their codes.

    Most newbies might not know this…

    • WPBeginner Support says:

      Actually we do not recommend editing plugins and themes from WordPress admin area. Instead, we would recommend editing your plugins in a text editor via FTP client. This way in case of an error you would be able to quickly fix it without losing access to admin area for too long.

  5. Mark Holland says:

    Thank you thank you thank you!! This has solved an issue that’s been puzzling me for weeks – and now solved in less than 1 minute.

    Can’t express how grateful I am for you sharing your knowledge – thanks again!

  6. Luca says:

    Thank you for the advice! But now I’m confused: what’s the difference between this method and the plugin “Code Snippet”? Is the result the same? Or do they accomplish the same thing in a different way?

  7. Malcolm says:

    Three years later this post is still giving – It’s changed the way I think about customising wordpress – Thank you!

    I tried this today and created a a site-specific-plugin with code to hide the wordpress menu bar for non-admins, and to add my latest post to a ‘Current issue’ menu item. Both worked perfectly.

    But the third snippet I added to the plugin failed to work. When I copied the code to the child theme’s functions.php it worked as expected.

    Can you explain why this would happen?

    I’m trying to modify the effect of the plugin “Restricted Site Access” by allowing access to more than a single page. The code I tried in my site specific plugin and the functions.php was:

    add_filter( ‘restricted_site_access_is_restricted’, ‘my_restricted_check’ );
    function my_restricted_check( $is_restricted ) {
    global $wp;
    if (
    $wp->query_vars[‘pagename’] == ‘contact’ ||
    $wp->query_vars[‘pagename’] == ‘subscribe’ ||
    $wp->query_vars[‘name’] == ‘aplr-2013-volume-21-number-2’
    $is_restricted = false;

    return $is_restricted;

    Any advice or comment would be welcome. I’m confused!

  8. harklord says:

    after trying this. My site is opening blank… Please help.. Av tried deleting the files i created but still blank

  9. WPBeginner Staff says:

    Make sure that your stored the plugin’s php file in /wp-content/plugins/ folder and not in your theme directory.

    • Mohammed Amine says:

      Fixed, actually it is necessary to add that php comment in the php file, or else it wont appear on the admin panel.
      That php comment is used to show the discription of the plugin in the admin panel.

  10. Paolo Bergomi says:

    This is Paolo, i am building my website and theme with WP last edition 4.1.1.
    i Am trying to learn custom type fields and I found your website very useful. i hav ea issue, though: even if following this post i created the folder my theme plugin and with the related file .php you mentioned here, for the site specific plugin, copy all in localhost using WAMP server. i opened then my dashboard, went to plugins but my new plugin dont appear. what is going on? did i miss anything? thanks

  11. WPBeginner Staff says:

    You can try and fit your modifications in site-specific plugin by using filters. However, since you had to edit specific files we doubt that all your edits can be implemented in a site-specific plugin using filters. In that case you should make those changes into a child theme. All your custom CSS should also go into your child theme’s stylesheet. You can also use your site-specific plugin to enqueue a custom stylesheet.

  12. Bas van der Linden says:

    Hmm, looks like my last post went missing while registering for this annoying disqus plugin.

    At first I’d like to thank you for sharing this information.

    Secondly I do have several questions regarding this post.

    1) Is it possible to also make site specific plugins for other .php’s where I’ve added some codes?
    Such as front-page.php post-page.php and post-archives.php

    2) Is it possible to do something like this for .css codes?
    I run genesis as framework(Parent theme) and a child-theme that I’ve downloaded.
    Now since there are no grand-child theme’s in wordpress I’ve made my alterations in the child-theme’s folder

    This includes a lot of different .css edits, Is there a way to make site specific .css files/plugins like this, so I can maintain the origional child-theme (and perform an update if any updates are released)?

    3) When I create a site-specific plugin to change the footer and activate it, I will see both the origional footer and my own footer on the site.
    Is there a way to go around this?

    My plugin looks like this:

    Once again thank you for sharing this information on site-specific plugins, and I hope to hear soon from you guys.

  13. Chelsey says:

    Thank you for your patience… I’m still trying to figure out how to ‘create a new folder to plugins directory’ :-)

    • Rodney Lacambra says:

      Hi Chelsey. Consider this guide:

      Go to “File Manager”. It will take you to “/public_html” directory. Click on “wp-content >> plugins” . This is where you will “create” a folder called “yoursitename-plugin”. After that, create a file using some text editor(notepad++), paste the code given above and save the file as “yoursitename-plugin.php”. Upload it to “yoursitename-plugin” folder and activate it in your wordpress admin area. Easy as that!

      Hope it helps you a lot.


      • Benjamin Mukasa says:

        This is a great post. I followed the instructions but the plugin is not appearing in my plugin list.

        • Paolo Bergomi says:

          me same..where did we make wrong? thanks in advance for any tips to solve this

  14. WPBeginner Staff says:

    yes you can use it for multiple functions.

  15. WPBeginner Staff says:

    Your code seems to be correct. Here is what you can do:

    Make sure you have saved the plugin file in the /wp-content/plugins/ directory.

    Make sure that your plugin file name is correct. We recommend using yoursitename.php format. For example if your domain name is black-circles then your plugin file name should be black-circles.php

    • SteveMTNO says:

      I originally had the plugin file (bc-plugin.php) in its own directory called blackcircles/wp-content/plugins/bc-plugins. That didn’t work.

      Then I tried moving the bc-plugin.php file from that folder to the blackcircles/wp-content/plugins folder. Still doesn’t show up in my admin panel.

      Do I have to “enable” it first before it shows up or something?


      • WPBeginner Staff says:

        If the file is correctly placed in your plugins folder then you will see it in your WordPress admin area under Plugins. If you see your plugin there, then you will have to click on the activate link below the file to activate the plugin.

        Did you try renaming the file to something else?

        • SteveMTNO says:

          Tried renaming it 3 times – none of them show up….

          I must be doing something wrong (or not doing something that I should be doing)…

        • SteveMTNO says:

          So can I use this one site-specific plugin for multiple functions, or is it best to do something similar to this for each one?

    • Michael Cuomo says:

      I’m having a similar issue with mine. I’ve created a site specific plugin to create a custom content type, but the custom content type is not showing up in my admin panel underneath pages like it should.

  16. SteveMTNO says:

    I posted this yesterday, but it seems to have vanished… :(

    Anyway, I followed the instructions above, but can’t see the site-specific plugin in my admin panel.

    Here’s a link to my code:

  17. SteveMTNO says:

    I followed all of the instructions above, but my plugin doesn’t appear in my admin panel.

    Here’s my pastebin link:



  18. WPBeginner Staff says:

    There were spaces in your PHP opening and close tags
    is the closing tag there is no space between them. See the corrected version here and compare it with your code. Hope this helps

  19. UgochukwuEmmanuelAgbams says:

    i got this message while trying to install it.

    The package could not be installed. No valid plugins were found.

  20. Rajesh Ghadge says:

    Very useful aticle it can help any novice in the designing field thanks a million

  21. Joe Librizzi says:

    This is a fantastic post, thanks! Quick question – could this same method be used to modify an existing plugin, sort of like you can use a child theme to modify existing CSS? I know you can modify a plugin directly, but I’m trying to avoid losing the modifications when the plugin is updated.

    • WPBeginner Support says:

      Joe, yes this can be used to modify plugins. Another way to modify plugins safely is by changing their header information. You can use the header shown in the above code as an starting point.

  22. Correen says:

    Successful! Thanks for showing me how to get this accomplished.

  23. Chris says:

    I am new at this and learning as I go but I am confused as in the instructions both the singular and plural version of plugin was used. Am I to create one plugin file to put all snippets into or seperate plugins for each code/snippet/task?

    For example – I found this article by gooling for how to create more than one custom post type. Would I put each custom post type into a seperate plugin?

    Or could the code for custom post type go into the same plugin file as theme support for post thumbnails as I have it currently in my functions.php?

  24. Shemul says:

    what about custom.css? can we made something like this. it is good to have child theme then.

    • WPBeginner Support says:

      A child theme is always recommended but there is a fine line as to how much functionality themes should have and what functionality should fall under plugin domain.

  25. Sussie T says:

    Great article. I did this, and it was very easy. But now I am taking this further and made another file to my plugin for the site specific widgets. My first widget.
    Have fully created 2 widgets, but only the last one is showing in admin. I guess is something with hooks or register_widget, but i cant crack this one.
    Seams like an easy error to solve, if you got the experience. But for a beginner Google is not helping at all.

    Resume of my widget file:

    widget script
    widget script

    a function witch registers my 2 widgets

    Outside this function is add_action(widgets_init, name of above function)

    Please help

  26. paul says:

    so when i read
    Paste this code in your theme’s functions.php file or your site-specific plugin
    i just create this site-specific plugin and add code to this rather than my functions.php

  27. Duy Dang says:

    Thank you so much, it’s very useful!

  28. Junior Godoi says:

    And what about mu-plugins folder?

  29. Max says:

    Your site is god sent! I’ve literally been going through each of your tutorials, making a list of all the one’s I’m going to be implementing on my new site I’m developing. Some things you have covered, I would of never even have thought about, but now I am definitely dong them. Thanks for all the information you provide with your blog.

    • Editorial Staff says:

      Thanks a lot for the kind words Max. Let us know if you have any questions or suggestions by using our contact form.

  30. Hamza Aid says:

    I’m managing a heavy loaded WP portal, and I found many problem when performing modifications because the developer made the same mistake, and put all the code (functions, etc..) in functions.php

    Now, I re-designed the portal, and separated many functions to site specific plugins. Thanks for this great post

  31. Mattia Frigeri says:

    It must be said.
    This is a superlative post.

  32. Greg says:

    I am not sure what it is I am doing wrong. I have done exactly as you have said and I can not get it to show in my WordPress Plugins.

    I have FTP’s it in, zipped it and tried to upload it via the admin and activating it (wp actually recognized it, and when I clicked the “Activate” link …. nada. It is like it was never there and when I FTP’d back in, it wasn’t there either.

    So I am trying Brent Logan’s plugin he mentioned (Code Snippets).

    Hopefully I’ll have better luck.
    I appreciate the article though. Thanks.

    (I am not that new to this. I have played with WordPress and Drupal and their plugins quite a bit. I am not sure why it is that I am having so much trouble with it.)

    comment would be appreciated — and I will keep reading here as well.

    • Editorial Staff says:

      That is actually very weird. Even when you FTP this, the file goes away from the folder?

  33. Billy Patton says:

    …I tried to keep this method a secret. hahaha

  34. Brent Logan says:

    I was doing this until I found the Code Snippets plugin. This plugin makes it easy to add multiple snippets, with a place for easy descriptions, and then activate or deactivate the snippets individually. Quite slick.

  35. b.nijhoff says:

    I always thought it was really hard but after seeing this I now know I could do it to. Thanks for sharing this, all your articles have been really helpful so far. Keep on the good work!

  36. ericsavina says:

    What I don’t get is that I keep reading everywhere that I should modify the functions.php instead of adding plugins. It is supposed to make the site faster. So, who should I trust? The idea of having a separate file for a the changes I’m making to the funtions.php file seems very interesting. At least, I would be able to easily update my theme without having to check every time the customs changes I made.

    • CreativeBoulder says:

      @ericsavina From what I have been gathering, and I’ve been doing this for a good while, is that the speed and performance using a ton of PHP in your functions.php versus additional plugins that use the same code– I was not able to find much of a difference in speed. Now, anybody correct me if I am wrong and if anybody has different performance comparisons.

      At this point, I’m using my functions.php file as I outlined to keep my functions organized along with a few custom plugins that I have designed with multi-site purpose. Hope that all makes sense.

      • ericsavina says:

        @CreativeBoulder Thanks for your answer. I will create this plugin and check if there are any differences in loading time.

        • CreativeBoulder says:

          @ericsavina Not a problem. Please let me know if you find out some different results than I did? Google Chromes Web Developer Tools have been more than helpful in performance and load-time and same with

  37. CreativeBoulder says:

    I fully understand the reasoning behind this setup. I really like the concept. When WordPress Upgrades, then you might need to upgrade some of your functions instead of having to navigate a possibly unorganized file structure. I was thinking about this about a week ago when working on a client site and did this with my functions.php:


    // Require Administrator Functions/Classes


    // require Custom WP Plugins (By BusinessName)









    Which allowed me to basically work on certain aspects and know where certain custom widgets or shortcodes were instead of a huge functions.php file. What do you think? Which method works better for you?

    • affanruslan says:

      @CreativeBoulder No, this function.php file is within your theme file, not the core wordpress file :)

      • CreativeBoulder says:

        @affanruslan I fully understand what the concept here is. Thanks for the reply. The goal of creating a Site Specific Plugin is to keep your functions, widgets, short-codes (etc) separate so that they are easier to work with and more organized. My concept of using your Theme Specific functions.php and “modularizing” it into separate files is just as easy to stay organized. That’s what I was getting at. I appreciated this post. =)

  38. tomdana says:

    At first I was confused on what this Post was about. Once I read it I realized the usefulness of doing exactly what you suggest. I named my plugin “site-specific-functions”. Thanks for the information and all you do.

  39. tomdana says:

    At first I was confused on what this Post was about. Once I read it I realized the usefulness of doing exactly what you suggest. I named my plugin “site-specific-functions”. Thanks for the information and all you do.

  40. fergusonsarah says:

    It’s really great to read such a valuable blog post here, thanks for sharing.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.