Your WordPress Site Needs a Plugin
Do you want to know what one of the worst pieces of WordPress advice is?
Just paste this code into your theme’s functions.php file
So many tutorials give this advice because it’s easy. When people follow this advice blindly, they can end up putting things in their theme, that should be in a plugin. Let’s talk about why this is bad. If you put something in your theme that your site relies upon, and you switch your theme, you’ll lose it. Your initial thought might be a theme doesn’t need to change. Actually, there are multiple reasons why you might want to change your theme
- Change new design
- Try out a n new theme to see if you like it
- Testing if an issue occurs in another theme
- You have a child theme for a seasonal event
While it’s technically possible to run a site with zero plugins, every site should have at least one. This plugin should contain things that are specific to your website.
Theme Responsibilities
Every WordPress website uses a theme to display it’s content and control it’s appearance. So anything that directly relates to the presentation of the content including:
- Templates
- Pagination
- Sidebars
- Menus
- Widgets
- Loading CSS and JS files
- Media
- Photos
- Media sizes
- Customizer
Plugin Responsibilities
Plugins are used to add behavior or functionality. Here’s a list of some things best put in your plugin:
- Short codes
- Custom Post Types
- Custom Taxonomies
- Widgets
- Meta Boxes
- Settings Pages
- Working with Users
Sometimes The Lines get Blurry
There are times when things can be put in either your theme or your plugin. Some aspects need to be in both. Where and how the code, can affect how easy it is to manage in the future. A theme developer selling their themes will make different decisions than a site owner. A theme developer will put everything in the theme. It gives them a single place to manage everything.
- Accessibility
- Internationalization
- Localization
- Security
Here’s how I make the decision on whether to put something in a theme or a plugin. I ask myself one question: “If I change the theme, will I lose the functionality?” If not, it can stay in the theme – otherwise it belongs in the plugin.