Theme Tip 8 – Moving theme functions to plugins

by

in

This tip is not for everyone, especially if you are just getting started with WordPress themes but I think it’s something that I personally could do with doing more myself so thought it would be worth sharing with the community.

Yoast and Ryan Imel of WPCandy had a really good discussion about the theme functions file on the WordPress Podcast last week about moving important functions in your theme functions file into a WordPress plugin.

Take the following scenario. You’ve spent a year tweaking and tuning your WordPress theme to a point where you’re really happy with it. It’s a thing of beauty – like a highly tuned sports car that purrs as the pixels render beautifully on your screen…..

….and then your boss calls you to tell you your company is rebranding and you need to rebuild the website completely. It is at this point you realise to your horror that there about literally dozens of nice little code snippets wrapped up in your theme functions file that you’ll now need to strip out, port to a new theme and figure out exactly how it works – again.

Not nice folks. If there’s one thing we all hate it’s having to redo something we’ve already done!

So here’s something worth considering – why not port your nice custom functions to a plugin? Ok so it’s going to take a little bit more effort but if you’re running a website that will be chopping and changing any time soon it might be worth going the plugin route.

Take a simple example, the humble breadcrumb. Many people wrap this up in a theme function file. Don’t; either build your own plugin – or – even better – use one that’s already out there and proven the test of time!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *