Functions.php vs. Functionality Plugin

WordPress Functions.php vs. Functionality Plugin

Many WordPress developers before me have discussed the difference between a theme’s functions.php file & creating a functionality plugin (WP Candy, Ottopress, WP BeginnerJustin Tadlock (several times), Ryan Cowles, etc.). With the proliferation of premium WordPress themes, it seems as though many developers are packing their themes with boatloads of functionality. This is probably in an effort to create an all-in-one website solution, so a user only has to install one thing (the theme), and they have everything they need.

This is not how WordPress was designed.

Themes vs. Plugins

WordPress themes exist to create the overall design & layout of a website. Together, the design & layout determine what the content looks like when it is presented to the user.

WordPress plugins exist to create the website’s functionality, as well as anything that comprises an integral part of the website.

If you were to re-brand your company tomorrow—changing your logo, colors, fonts, and entire brand message—you would obviously need to change your theme. But the website still needs to function exactly as it does now. And all of your content should remain in tact, categorized exactly how it has been for years. Users should have the same capabilities. The admin area shouldn’t look any different.

WordPress Functions.php vs. Functionality Plugin table
Ryan Imel’s breakdown of what code goes where.

Themes are for design, colors, fonts, spacing & layout.

Plugins are for content, functionality & admin functions.

What goes in a functionality plugin vs. theme functions.php?

Ryan Imel of WP Candy has a table that breaks down what functions belong in a plugin vs. a theme’s functions.php file.

I’d like to expand upon it even further and create a table of my own. Here is my breakdown:

Code Functionality Plugin Theme functions.php
Adding styles & scripts Depends (frameworks, fonts, resets) Depends (theme styles & other theme-specific)
Support for post thumbnails & post formats Always
Creating widgetized areas (register_sidebar) Always
Creating actual widgets Always
Registering menus Always
Creating shortcodes Always
Custom post types & taxonomies Always
Create custom image sizes Depends (if you’ll use them regardless of theme) Depends (if theme-specific)
Customize WordPress admin & dashboard Always
Custom login styles for wp-login.php Depends (if generic with logo & custom message) Depends (if highly customized to match theme)
Google Analytics code Always
User functions & profile fields Always
Gravatar functions Always
Add classes to body_class & post_class Always
Changes to the <head> section Always

One Plugin vs. Several

After hours of research on theme functions vs. functionality plugins, I decided to create a functionality plugin with many of the same functions that we use over and over again. I ended up creating one plugin, which contains sub-folders to organize the various functions into logical chunks of code.

You can view & download my WordPress Custom Functions plugin on github.

However, now that I’ve gone through this entire process, I’m starting to think it makes more sense to create multiple functionality plugins. Here’s the reasoning:

  • If there’s an issue on the site, it’s easier to debug by simply deactivating a plugin
  • You can turn features on & off if you suspect there are conflicts, or you need to create some fixes before it’s operational again

With all functions contained in one plugin, the debugging becomes more difficult, and the code gets messy commenting things out.

My next few mini-projects will hopefully consist of creating a group of small, one-off plugins that I’ll upload to the WordPress.org plugin repository for the community to pick-and-choose which features they’d like to add to their site.

Further Resources

What Are Your Thoughts?

All fields are required. Your email will not be published.

You can use standard <code> and <pre> tags to post code examples, or a service like codepen.io.