Categories
Uncategorised

Plugin or Theme Functions?

Although WordPress is an impressively robust piece of software to start with, its real value comes from the ability to customise it to suit the varying needs of different sites and clients.

It provides two interfaces for doing this – plugins and themes. Although there are differences between the two, it’s often possible to accomplish the same thing using either.

If you wonder which method to use, this article is for you.

Changing Your Theme

You can run only one theme at a time. This means that if you’ve been adding code to your theme functions and you want to change your theme, any code that you want to keep needs to be transferred over to your new theme. It won’t be run from your old theme.

If the prospect of sorting through unfamiliar code is unappealing to you, contact me and I can move over your code.

Unlike themes, you can run as many plugins as you want at a time, and they are independent of your theme. This means that if you do change your theme, all your plugins will continue to work seamlessly and you can avoid the hassle of transferring code.

Plugin Downsides

There are downsides to using plugins too.

Firstly, if you’re using a lot of plugins, it could slow down your site. The theme functions method may be faster because all the code is consolidated into one file, as opposed to plugins where each solution is in a separate file. However, the difference is usually not significant enough to be noticeable.

Secondly, there are some cases where code that makes reference to ‘genesis’ will work if pasted into your theme functions, but not from within a plugin – even if you’re running a Genesis theme. I always test the code I share and ensure it can be run from within a plugin, but if you’re an advanced user and you create your own plugins to store blocks of code that were meant for your theme functions, you might come across this.

Genesis Check

Some pieces of code may require your site to be running Genesis. If you aren’t running a Genesis theme and the code makes reference to ‘genesis’, the code won’t work whether it’s in a theme or a plugin.

If you use the theme functions method, you can always check to see a notice reading ‘this theme inherits from Genesis’, which is circled in the screenshot below, and only add the Genesis code if the notice is present.

Screenshot of the notice that a theme inherits from Genesis

If you’ve been implementing solutions that require Genesis, what would happen if you were to ever switch to a non-Genesis theme?

If you implemented the solutions using the plugin method and you leave those plugins active, you’re in trouble. The solutions will either stop taking effect, or worse, bring down your whole site.

If you implemented the solutions using the theme functions method, then the solutions you added will stop taking effect, but your site will stay afloat. That’s provided you don’t move them over into your new theme – then they could potentially bring down your site.

Conclusion

In conclusion, it’s not an easy question to answer. There are pros and cons for both methods. If you’re in doubt, get in touch and I’ll advise you.