WordPress Site Plugins
As you use WordPress, you learn good themes and plugins make all the difference in your WordPress experience. Every WordPress site needs a theme to display it’s content. Each plugin changes the way that WordPress works. WordPress doesn’t require you to use a plugin. People use them because they’re useful. Usually a plugin adds functionality, but it can also remove functionality. While it’s possible to run a WordPress site without a plugin, every website should have at least one — one specifically for your website.
Your website has unique needs. Creating your own site plugin allows you to develop the functionality to support it. As your website matures, you’ll likely change your theme at least once. When you change your theme, you should be able to preserve your website functionality, and not worry about things breaking. Creating your own site plugin, lets you do just that.
Many WordPress tutorials instruct you to paste this code into your functions.php
, because it’s an easy instruction to give. The author of the article doesn’t need to know about the readers setup; Nor can they know. More often than not though, the code doesn’t belong in your functions.php. Unless it only affects the site’s appearance, code should be in a plugin.
Deciding Theme vs. Plugin
Themes are responsible for the appearance of the website. They’re akin to the view in the MVC design pattern. Themes should only contain things that deal primarily with presentation/UI – sidebars, template tags, stylesheets. Everything else should be in a plugin – content types, widgets, shortcodes, taxonomies. There’s a simple test to tell whether something should be in a theme or a plugin – When you change your theme, will your site appear broken?
The best way to build a site plugin is to start small, group like things together, and build. Don’t try to do too much at once.