How would I create a plugin for my shortcodes?

All we need is an easy explanation of the problem, so here it is.

All tutorials I have found say to add your shortcodes to functions.php in your theme. I would like to break that away from my theme and put that in a plugin so I can share these shortcodes between my network of blogs. Is there a reference or tutorial on creating these shortcodes in a plugin?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Code in functions.php and plugins works in almost exactly same way (except than stage at which it is loaded and some plugin-specific hooks).

Basically you just take your code out of functions.php, place it in plugin and it still works. It is good practice to use naming conventions and checking for functions definitions so it doesn’t explode if you accidentally load both copies.

But there will be no difference in how code actually works.

See Writing a Plugin for a starting point.

Method 2

Basically, you just prepend your functions with a plugin header.

As a really simple example, I just put my shortcode plugin to GitHub:

It is missing I18n โ€“ as usual ๐Ÿ™‚ โ€“ but it should give you some hints.

Note: Use and implement method 1 because this method fully tested our system.
Thank you ๐Ÿ™‚

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply